Loading...
Searching...
No Matches
tm.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 René Kijewski
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
17#ifndef TM_H
18#define TM_H
19
20#include <time.h>
21#include <sys/time.h>
22#include <stdint.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#define TM_WDAY_SUN (0)
29#define TM_WDAY_MON (1)
30#define TM_WDAY_TUE (2)
31#define TM_WDAY_WED (3)
32#define TM_WDAY_THU (4)
33#define TM_WDAY_FRI (5)
34#define TM_WDAY_SAT (6)
36#define TM_MON_JAN ( 0)
37#define TM_MON_FEB ( 1)
38#define TM_MON_MAR ( 2)
39#define TM_MON_APR ( 3)
40#define TM_MON_MAY ( 4)
41#define TM_MON_JUN ( 5)
42#define TM_MON_JUL ( 6)
43#define TM_MON_AUG ( 7)
44#define TM_MON_SEP ( 8)
45#define TM_MON_OCT ( 9)
46#define TM_MON_NOV (10)
47#define TM_MON_DEC (11)
53extern const int8_t TM_MON_DAYS[12];
54
59extern const int16_t TM_MON_DAYS_ACCU[12];
60
66int tm_is_leap_year(unsigned year);
67
74int tm_doomsday(int year);
75
85#ifndef ATMEGA_INCOMPATIBLE_TIME_H
86void tm_get_wyday(int year, int mon, int mday, int *wday, int *yday);
87#else
88void tm_get_wyday(int year, int mon, int mday, int8_t *wday, int16_t *yday);
89#endif
90
98void tm_fill_derived_values(struct tm *tm);
99
108int tm_is_valid_date(int year, int mon, int mday);
109
118int tm_is_valid_time(int hour, int min, int sec);
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* TM_H */
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.