ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
time.h
Go to the documentation of this file.
1 
26 #ifndef TIME_H
27 #define TIME_H
28 
29 #define EPOCH_YEAR 1970 /*< Thursday Jan 1 1970 */
30 #define EPOCH_DAY 4 /*< Sunday = 0 ... Saturday = 6 */
31 #define EPOCH 0 /*< Zero seconds */
32 #define EPOCH_2000 946684800 /*< Sat, 01 Jan 2000 00:00:00 GMT */
33 
35 typedef uint32_t time_t;
36 
39 
41 struct tm
42 {
43  int tm_sec; /*< Seconds. [0-60] (1 leap second) */
44  int tm_min; /*< Minutes. [0-59] */
45  int tm_hour; /*< Hours. [0-23] */
46  int tm_mday; /*< Day. [1-31] */
47  int tm_mon; /*< Month. [0-11] */
48  int tm_year; /*< Year - 1900. */
49  int tm_wday; /*< Day of week. [0-6] */
50  int tm_yday; /*< Days in year.[0-365] */
51  int tm_isdst; /*< DST. [-1/0/1] */
52  int32_t tm_gmtoff; /*< GMT offset in seconds */
53 };
54 
63 typedef struct tm tm_t;
65 
66 
68 struct timeval
69 {
70  time_t tv_sec; /*< seconds */
71  uint32_t tv_usec; /*< microseconds */
72 };
73 
75 typedef struct timeval tv_t;
76 
78 struct timezone
79 {
80  int tz_minuteswest; /*< minutes west of Greenwich */
81  int tz_dsttime; /*< type of DST correction */
82 };
83 
85 typedef struct timezone tz_t;
86 
88 struct timespec
89 {
90  time_t tv_sec; /*< seconds */
91  long tv_nsec; /*< nanoseconds */
92 };
93 
95 typedef struct timespec ts_t;
96 
98 extern volatile ts_t __clock;
99 
101 extern tz_t __tzone;
102 
103 
105 typedef struct {
109 } dst_t;
110 
111 /* time.c */
112 MEMSPACE char *tm_wday_to_ascii ( int i );
113 MEMSPACE char *tm_mon_to_ascii ( int i );
114 MEMSPACE int finddayofweek ( int year , int month , int day );
115 MEMSPACE int Days_Per_Month ( int month , int year );
116 MEMSPACE time_t time_to_tm ( time_t epoch , int32_t offset , tm_t *t );
117 MEMSPACE time_t timegm ( tm_t *t );
118 MEMSPACE char *asctime_r ( tm_t *t , char *buf );
119 MEMSPACE char *asctime ( tm_t *t );
120 MEMSPACE char *ctime_r ( time_t *t , char *buf );
121 MEMSPACE char *ctime ( time_t *tp );
122 MEMSPACE char *ctime_gm ( time_t *tp );
123 MEMSPACE tm_t *gmtime_r ( time_t *t , tm_t *result );
124 MEMSPACE tm_t *gmtime ( time_t *tp );
125 MEMSPACE tm_t *localtime_r ( time_t *t , tm_t *result );
126 MEMSPACE tm_t *localtime ( time_t *tp );
127 MEMSPACE time_t mktime ( tm_t *t );
128 MEMSPACE time_t normalize ( tm_t *t , int normalize_to_timezone );
129 MEMSPACE int gettimezone ( tz_t *tz );
130 MEMSPACE int settimezone ( tz_t *tz );
131 MEMSPACE int gettimeofday ( tv_t *tv , tz_t *tz );
132 MEMSPACE time_t time ( time_t *t );
133 MEMSPACE int settimeofday ( tv_t *tv , tz_t *tz );
135 MEMSPACE int setdate ( void );
136 MEMSPACE int setdate_r ( char *buf );
137 MEMSPACE time_t find_dst ( int dst , time_t epoch , int year , int month , int weekno , int dayno , int hour );
138 MEMSPACE void set_dst ( time_t epoch );
139 MEMSPACE int is_dst ( time_t epoch );
140 MEMSPACE void print_dst ( void );
141 MEMSPACE void print_dst_gmt ( void );
142 MEMSPACE void initialize_clock ( int minwest );
143 MEMSPACE void display_clock ( void );
144 
145 
146 
147 
148 #endif
int int32_t
int tz_dsttime
Definition: time.h:81
int tm_min
Definition: time.h:44
MEMSPACE char * ctime_gm(time_t *tp)
GMT version of POSIX ctime().
Definition: time.c:441
dst_t dst
DST start and stop in GMT epoch.
Definition: time.c:52
MEMSPACE char * ctime(time_t *tp)
Convert local time_t *t epoch time into POSIX asctime() string buf[].
Definition: time.c:424
unsigned short uint16_t
Definition: send.c:18
MEMSPACE time_t time(time_t *t)
Return second from epoch - POSIX function.
Definition: time.c:843
MEMSPACE time_t find_dst(int dst, time_t epoch, int year, int month, int weekno, int dayno, int hour)
Calculate GMT seconds of DST transition given LOCAL time start / end time and DST flag...
Definition: time.c:1038
int tm_mday
Definition: time.h:46
MEMSPACE char * asctime(tm_t *t)
Convert tm_t *t structure into POSIX asctime() ASCII string.
Definition: time.c:394
uint16_t clockid_t
type of clockid_t.
Definition: time.h:38
MEMSPACE int Days_Per_Month(int month, int year)
days in a month
Definition: time.c:223
MEMSPACE int settimezone(tz_t *tz)
Set current timezone with struct timezone *tz - POSIX function.
Definition: time.c:806
MEMSPACE int setdate(void)
Set date and time by prompting user.
Definition: time.c:901
int tm_year
Definition: time.h:48
unsigned int uint32_t
Definition: send.c:19
time_t tv_sec
Definition: time.h:70
time_t end
Start of local DST in GMT.
Definition: time.h:107
MEMSPACE int is_dst(time_t epoch)
Test GMT epoch time to see if DST applies in a local timezone.
Definition: time.c:1147
time_t tv_sec
Definition: time.h:90
MEMSPACE tm_t * gmtime(time_t *tp)
Convert epoch GMT time_t *tp into POSIX static tm_t *t.
Definition: time.c:471
MEMSPACE char * ctime_r(time_t *t, char *buf)
Convert local time_t *t epoch time into POSIX asctime() ASCII string *buf.
Definition: time.c:410
uint32_t time_t
type of EPOCH result.
Definition: time.h:35
int tm_mon
Definition: time.h:47
MEMSPACE int setdate_r(char *buf)
Set date and time from string in this format "YYYY MM DD HH:MM:SS".
Definition: time.c:919
long tv_nsec
Definition: time.h:91
MEMSPACE tm_t * gmtime_r(time_t *t, tm_t *result)
Convert epoch GMT time_t *tp into POSIX tm_t *result.
Definition: time.c:456
MEMSPACE void print_dst(void)
print start/stop for DST as localtime for this year
Definition: time.c:1158
MEMSPACE int gettimeofday(tv_t *tv, tz_t *tz)
Get current time struct timeval *tv and struct timezone *tz - POSIX function. We assume a GMT hardwar...
Definition: time.c:822
MEMSPACE void clock_set(uint32_t seconds, uint32_t us)
Set system clock with seconds and microseconds.
Definition: time.c:882
MEMSPACE char * tm_wday_to_ascii(int i)
Get string Short name of day from day number.
Definition: time.c:87
MEMSPACE void print_dst_gmt(void)
print start/stop for DST as GMT for this year
Definition: time.c:1166
time_t start
Definition: time.h:106
MEMSPACE time_t mktime(tm_t *t)
convert tm_t structure to time_t local time epoch
Definition: time.c:534
MEMSPACE time_t normalize(tm_t *t, int normalize_to_timezone)
Normalize POSIX tm_t *t struct and convert to epoch time Note: does not deal with DST - by design...
Definition: time.c:654
MEMSPACE time_t timegm(tm_t *t)
Convert tm_t structure as GMT time into GMT seconds since 1900. All calculactions are in GMT regardle...
Definition: time.c:347
MEMSPACE tm_t * localtime_r(time_t *t, tm_t *result)
Convert POSIX epoch time_t *tp into POSIX tm_t *result expressed as local time using timezone and DST...
Definition: time.c:499
POSIX timeval.
Definition: time.h:68
time_t epoch
End of local DST in GMT.
Definition: time.h:108
MEMSPACE void set_dst(time_t epoch)
Set DST start and end time for the given epoch year.
Definition: time.c:1113
int32_t tm_gmtoff
Definition: time.h:52
MEMSPACE int settimeofday(tv_t *tv, tz_t *tz)
Set current time struct timeval *tv and struct timezone *tz - POSIX function. We assume a GMT hardwar...
Definition: time.c:861
uint32_t tv_usec
Definition: time.h:71
tz_t __tzone
System Time Zone.
Definition: time.c:49
MEMSPACE time_t time_to_tm(time_t epoch, int32_t offset, tm_t *t)
Converts epoch ( seconds from 1 Jan EPOCH_YEAR UTC), offset seconds, to UNIX tm *t.
Definition: time.c:262
DST structure.
Definition: time.h:105
MEMSPACE char * tm_mon_to_ascii(int i)
Get string Short name of Month from month number.
Definition: time.c:114
POSIX struct tm.
Definition: time.h:41
int tm_wday
Definition: time.h:49
MEMSPACE tm_t * localtime(time_t *tp)
Convert POSIX epoch time_t *tp into POSIX tm_t *result.
Definition: time.c:522
#define MEMSPACE
Definition: cpu.h:25
int tm_yday
Definition: time.h:50
volatile ts_t __clock
System Clock Time.
Definition: timer.c:38
MEMSPACE void display_clock(void)
Display system time and optionally RTC time.
Definition: time.c:1227
POSIX timespec.
Definition: time.h:88
int tm_sec
Definition: time.h:43
MEMSPACE char * asctime_r(tm_t *t, char *buf)
Convert tm_t *t structure into POSIX asctime() ASCII string *buf.
Definition: time.c:367
MEMSPACE void initialize_clock(int minwest)
initialize system time - if we have an RTC use it
Definition: time.c:1178
int tm_hour
Definition: time.h:45
time_t seconds
Definition: user_main.c:293
POSIX timezone.
Definition: time.h:78
int tm_isdst
Definition: time.h:51
MEMSPACE int gettimezone(tz_t *tz)
Get current timezone in struct timezone *tz - POSIX function.
Definition: time.c:792
int tz_minuteswest
Definition: time.h:80
MEMSPACE int finddayofweek(int year, int month, int day)
return day of week for givenn day, month, year
Definition: time.c:180