time.h
Go to the documentation of this file.
1  
19   #ifndef HARDWARE_AVR_TIME_H
20   #define HARDWARE_AVR_TIME_H
21  
22   #include <stdint.h>
23   #include <string.h>
24  
30   typedef uint32_t time_t ;
31  
36   struct tm {
37   int8_t tm_sec ;
38   int8_t tm_min ;
39   int8_t tm_hour ;
40   int8_t tm_mday ;
41   int8_t tm_wday ;
42   int8_t tm_mon ;
43   int16_t tm_year ;
44   int16_t tm_yday ;
45   int16_t tm_isdst ;
46  
47   tm ()
48   {
49   memset( this , 0, sizeof ( tm ));
50   }
51  
52   tm (int8_t wday, int16_t year, int8_t mon, int8_t mday,
53   int8_t hour, int8_t min, int8_t sec) :
54   tm_sec(sec),
55   tm_min(min),
56   tm_hour(hour),
57   tm_mday(mday),
58   tm_wday(wday),
59   tm_mon(mon),
60   tm_year(year - 1900),
61   tm_yday(0),
62   tm_isdst(0)
63   {
64   }
65  } __attribute__((packed));
66  
67   enum {
68   SUNDAY ,
69   MONDAY ,
70   TUESDAY ,
71   WEDNESDAY ,
72   THURSDAY ,
73   FRIDAY ,
74   SATURDAY
75  };
76  
77   enum {
78   JANUARY ,
79   FEBRUARY ,
80   MARCH ,
81   APRIL ,
82   MAY ,
83   JUNE ,
84   JULY ,
85   AUGUST ,
86   SEPTEMBER ,
87   OCTOBER ,
88   NOVEMBER ,
89   DECEMBER
90  };
91  
96  int32_t difftime ( time_t time1, time_t time0);
97  
109   time_t mktime ( struct tm * timeptr);
110  
122   time_t mk_gmtime ( const struct tm * timeptr);
123  
128   struct tm * gmtime_r ( const time_t * timer, struct tm * timeptr);
129  
134   struct tm * localtime_r ( const time_t * timer, struct tm * timeptr);
135  
140   char * isotime_r ( const struct tm * tmptr, char * buf);
141  
145  uint8_t is_leap_year (int16_t year);
146  
148   #define ONE_HOUR 3600
149  
151   #define ONE_DEGREE 3600
152  
154   #define ONE_DAY 86400UL
155  
157   #define UNIX_OFFSET 946684800UL
158  
160   #define NTP_OFFSET 3155673600UL
161  
170   void set_dst ( int (*)( const time_t *, int32_t*));
171  
179   void set_zone (int32_t);
180  int32_t get_zone ();
181   #endif
int8_t tm_mday
Day in Month [1-31].
Definition: time.h:40
Definition: time.h:68
int8_t tm_min
Minutes [0-59].
Definition: time.h:38
Definition: time.h:85
Definition: time.h:80
char * isotime_r(const struct tm *tmptr, char *buf)
Definition: isotime_r.cpp:34
tm(int8_t wday, int16_t year, int8_t mon, int8_t mday, int8_t hour, int8_t min, int8_t sec)
Definition: time.h:52
Definition: time.h:88
int16_t tm_yday
days since January 1 [0-365].
Definition: time.h:44
int16_t tm_isdst
Daylight Saving Time flag [-1/0/1].
Definition: time.h:45
Definition: time.h:69
Definition: time.h:83
int32_t difftime(time_t time1, time_t time0)
Definition: difftime.cpp:32
Definition: time.h:79
time_t mktime(struct tm *timeptr)
Definition: mktime.cpp:35
Definition: time.h:78
Definition: time.h:70
struct tm * localtime_r(const time_t *timer, struct tm *timeptr)
Definition: localtime_r.cpp:35
int16_t tm_year
Years since 1900.
Definition: time.h:43
time_t mk_gmtime(const struct tm *timeptr)
Definition: mk_gmtime.cpp:32
int8_t tm_sec
Seconds [0-60].
Definition: time.h:37
uint32_t time_t
Definition: time.h:30
void set_dst(int(*)(const time_t *, int32_t *))
Definition: set_dst.cpp:34
Definition: time.h:82
struct tm * gmtime_r(const time_t *timer, struct tm *timeptr)
Definition: gmtime_r.cpp:33
int8_t tm_hour
Hours [0-23].
Definition: time.h:39
tm()
Definition: time.h:47
Definition: time.h:74
Definition: time.h:73
Definition: time.h:71
Definition: time.h:84
int8_t tm_wday
Days since Sunday [0-6].
Definition: time.h:41
Definition: time.h:36
Definition: time.h:72
Definition: time.h:81
Definition: time.h:87
int8_t tm_mon
0-11 Months since January [0-11].
Definition: time.h:42
Definition: time.h:89
uint8_t is_leap_year(int16_t year)
Definition: time.h:86
int32_t get_zone()
Definition: set_zone.cpp:40
void set_zone(int32_t)
Definition: set_zone.cpp:34