Loading...
Searching...
No Matches
tm.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 René Kijewski
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
15
16#include <time.h>
17#include <sys/time.h>
18#include <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#define TM_WDAY_SUN (0)
25#define TM_WDAY_MON (1)
26#define TM_WDAY_TUE (2)
27#define TM_WDAY_WED (3)
28#define TM_WDAY_THU (4)
29#define TM_WDAY_FRI (5)
30#define TM_WDAY_SAT (6)
31
32#define TM_MON_JAN ( 0)
33#define TM_MON_FEB ( 1)
34#define TM_MON_MAR ( 2)
35#define TM_MON_APR ( 3)
36#define TM_MON_MAY ( 4)
37#define TM_MON_JUN ( 5)
38#define TM_MON_JUL ( 6)
39#define TM_MON_AUG ( 7)
40#define TM_MON_SEP ( 8)
41#define TM_MON_OCT ( 9)
42#define TM_MON_NOV (10)
43#define TM_MON_DEC (11)
44
49extern const int8_t TM_MON_DAYS[12];
50
55extern const int16_t TM_MON_DAYS_ACCU[12];
56
62int tm_is_leap_year(unsigned year);
63
70int tm_doomsday(int year);
71
81#ifndef ATMEGA_INCOMPATIBLE_TIME_H
82void tm_get_wyday(int year, int mon, int mday, int *wday, int *yday);
83#else
84void tm_get_wyday(int year, int mon, int mday, int8_t *wday, int16_t *yday);
85#endif
86
94void tm_fill_derived_values(struct tm *tm);
95
104int tm_is_valid_date(int year, int mon, int mday);
105
114int tm_is_valid_time(int hour, int min, int sec);
115
116#ifdef __cplusplus
117}
118#endif
119
int tm_is_valid_time(int hour, int min, int sec)
Shallow test if a time is valid.
int tm_is_valid_date(int year, int mon, int mday)
Tests if a date is valid.
const int8_t TM_MON_DAYS[12]
The number of days in common years.
void tm_fill_derived_values(struct tm *tm)
Fills in struct tm::tm_wday and struct tm::tm_yday given a date.
void tm_get_wyday(int year, int mon, int mday, int *wday, int *yday)
Calculates the day of the year and the weekday of a given date.
const int16_t TM_MON_DAYS_ACCU[12]
The prefixsum of the number of days in common years.
int tm_doomsday(int year)
Returns the congruent weekday of the Doomsday (March 0).
int tm_is_leap_year(unsigned year)
Tells if a given year is a leap year in the Gregorian calendar.