Contiki 3.x
utc_time.h
Go to the documentation of this file.
1 /**
2  * @file
3  * Utility functions for operating on UTC times.
4  * Convenient functions for converting between the epoch and the tm struct.
5  */
6 
7 #ifndef UTC_TIME_H
8 #define UTC_TIME_H
9 
10 #include <stdint.h>
11 
12 typedef uint32_t time_t;
13 
14 /**
15  * tm
16  *
17  * An abbreviated version of tm struct from time.h. See Open Group for full
18  * documentation of this structure.
19  */
20 struct tm {
21  int tm_sec; // seconds [0,61]
22  int tm_min; // minutes [0,59]
23  int tm_hour; // hour [0,23]
24  int tm_mday; // day of month [1,31]
25  int tm_mon; // month of year [0,11]
26  int tm_year; // years since 1900
27 };
28 
29 /**
30  * Convert a UNIX epoch to a tm struct.
31  * @param timer The UNIX epoch
32  * @param tmp The tm struct to conver to
33  */
34 void epoch_to_tm(const time_t *timer, struct tm * const tmp);
35 
36 /**
37  * Convert a tm struct to a UNIX epoch.
38  * @param tmp The tm struct to convert
39  * @return The UNIX epoch
40  */
41 time_t tm_to_epoch(struct tm * const tmp);
42 
43 #endif // ifndef UTC_TIME_H
A timer.
Definition: timer.h:86
time_t tm_to_epoch(struct tm *const tmp)
Convert a tm struct to a UNIX epoch.
Definition: tm_to_epoch.c:112
tm
Definition: utc_time.h:20
void epoch_to_tm(const time_t *timer, struct tm *const tmp)
Convert a UNIX epoch to a tm struct.