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 #include "kernel_defines.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define TM_WDAY_SUN (0)
31 #define TM_WDAY_MON (1)
32 #define TM_WDAY_TUE (2)
33 #define TM_WDAY_WED (3)
34 #define TM_WDAY_THU (4)
35 #define TM_WDAY_FRI (5)
36 #define TM_WDAY_SAT (6)
38 #define TM_MON_JAN ( 0)
39 #define TM_MON_FEB ( 1)
40 #define TM_MON_MAR ( 2)
41 #define TM_MON_APR ( 3)
42 #define TM_MON_MAY ( 4)
43 #define TM_MON_JUN ( 5)
44 #define TM_MON_JUL ( 6)
45 #define TM_MON_AUG ( 7)
46 #define TM_MON_SEP ( 8)
47 #define TM_MON_OCT ( 9)
48 #define TM_MON_NOV (10)
49 #define TM_MON_DEC (11)
55 extern const int8_t TM_MON_DAYS[12];
56 
61 extern const int16_t TM_MON_DAYS_ACCU[12];
62 
68 int tm_is_leap_year(unsigned year) CONST;
69 
76 int tm_doomsday(int year) CONST;
77 
87 void tm_get_wyday(int year, int mon, int mday, int *wday, int *yday);
88 
96 void tm_fill_derived_values(struct tm *tm);
97 
106 int tm_is_valid_date(int year, int mon, int mday) CONST;
107 
116 int tm_is_valid_time(int hour, int min, int sec) CONST;
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* TM_H */
123 
const int16_t TM_MON_DAYS_ACCU[12]
The prefixsum of the number of days in common years.
int tm_is_valid_date(int year, int mon, int mday) CONST
Tests if a date is valid.
int tm_doomsday(int year) CONST
Returns the congruent weekday of the Doomsday (March 0).
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.
int tm_is_leap_year(unsigned year) CONST
Tells if a given year is a leap year in the Gregorian calendar.
Datatype to represent time.
int tm_is_valid_time(int hour, int min, int sec) CONST
Shallow test if a time is valid.
Common macros and compiler attributes/pragmas configuration.
void tm_fill_derived_values(struct tm *tm)
Fills in struct tm::tm_wday and struct tm::tm_yday given a date.
#define CONST
A function declared as CONST is PURE and also not allowed to examine global memory.