ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts
1.0
ESP8266ILI9341DisplayProject
|
Common Linux/POSIX time functions. More...
Go to the source code of this file.
Data Structures | |
struct | tm |
POSIX struct tm. More... | |
struct | timeval |
POSIX timeval. More... | |
struct | timezone |
POSIX timezone. More... | |
struct | timespec |
POSIX timespec. More... | |
struct | dst_t |
DST structure. More... | |
Macros | |
#define | EPOCH_YEAR 1970 /*< Thursday Jan 1 1970 */ |
#define | EPOCH_DAY 4 /*< Sunday = 0 ... Saturday = 6 */ |
#define | EPOCH 0 /*< Zero seconds */ |
#define | EPOCH_2000 946684800 /*< Sat, 01 Jan 2000 00:00:00 GMT */ |
Typedefs | |
typedef uint32_t | time_t |
type of EPOCH result. More... | |
typedef uint16_t | clockid_t |
type of clockid_t. More... | |
typedef struct tm | tm_t |
POSIX struct tm typedef. More... | |
typedef struct timeval | tv_t |
POSIX timeval typedef. More... | |
typedef struct timezone | tz_t |
POSIX timezone typedef. More... | |
typedef struct timespec | ts_t |
POSIX timespec typedef. More... | |
Functions | |
MEMSPACE char * | tm_wday_to_ascii (int i) |
Get string Short name of day from day number. More... | |
MEMSPACE char * | tm_mon_to_ascii (int i) |
Get string Short name of Month from month number. More... | |
MEMSPACE int | finddayofweek (int year, int month, int day) |
return day of week for givenn day, month, year More... | |
MEMSPACE int | Days_Per_Month (int month, int year) |
days in a month More... | |
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. More... | |
MEMSPACE time_t | timegm (tm_t *t) |
Convert tm_t structure as GMT time into GMT seconds since 1900. All calculactions are in GMT regardless of timezoe settings. More... | |
MEMSPACE char * | asctime_r (tm_t *t, char *buf) |
Convert tm_t *t structure into POSIX asctime() ASCII string *buf. More... | |
MEMSPACE char * | asctime (tm_t *t) |
Convert tm_t *t structure into POSIX asctime() ASCII string. More... | |
MEMSPACE char * | ctime_r (time_t *t, char *buf) |
Convert local time_t *t epoch time into POSIX asctime() ASCII string *buf. More... | |
MEMSPACE char * | ctime (time_t *tp) |
Convert local time_t *t epoch time into POSIX asctime() string buf[]. More... | |
MEMSPACE char * | ctime_gm (time_t *tp) |
GMT version of POSIX ctime(). More... | |
MEMSPACE tm_t * | gmtime_r (time_t *t, tm_t *result) |
Convert epoch GMT time_t *tp into POSIX tm_t *result. More... | |
MEMSPACE tm_t * | gmtime (time_t *tp) |
Convert epoch GMT time_t *tp into POSIX static tm_t *t. More... | |
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 corrections. More... | |
MEMSPACE tm_t * | localtime (time_t *tp) |
Convert POSIX epoch time_t *tp into POSIX tm_t *result. More... | |
MEMSPACE time_t | mktime (tm_t *t) |
convert tm_t structure to time_t local time epoch More... | |
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. More... | |
MEMSPACE int | gettimezone (tz_t *tz) |
Get current timezone in struct timezone *tz - POSIX function. More... | |
MEMSPACE int | settimezone (tz_t *tz) |
Set current timezone with struct timezone *tz - POSIX function. More... | |
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 hardware clock. More... | |
MEMSPACE time_t | time (time_t *t) |
Return second from epoch - POSIX function. More... | |
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 hardware clock. More... | |
MEMSPACE void | clock_set (uint32_t seconds, uint32_t us) |
Set system clock with seconds and microseconds. More... | |
MEMSPACE int | setdate (void) |
Set date and time by prompting user. More... | |
MEMSPACE int | setdate_r (char *buf) |
Set date and time from string in this format "YYYY MM DD HH:MM:SS". More... | |
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. More... | |
MEMSPACE void | set_dst (time_t epoch) |
Set DST start and end time for the given epoch year. More... | |
MEMSPACE int | is_dst (time_t epoch) |
Test GMT epoch time to see if DST applies in a local timezone. More... | |
MEMSPACE void | print_dst (void) |
print start/stop for DST as localtime for this year More... | |
MEMSPACE void | print_dst_gmt (void) |
print start/stop for DST as GMT for this year More... | |
MEMSPACE void | initialize_clock (int minwest) |
initialize system time - if we have an RTC use it More... | |
MEMSPACE void | display_clock (void) |
Display system time and optionally RTC time. More... | |
Variables | |
volatile ts_t | __clock |
System Clock Time. More... | |
tz_t | __tzone |
System Time Zone. More... | |
Common Linux/POSIX time functions.
This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file time.h.
#define EPOCH_2000 946684800 /*< Sat, 01 Jan 2000 00:00:00 GMT */ |
#define EPOCH_DAY 4 /*< Sunday = 0 ... Saturday = 6 */ |
Definition at line 30 of file time.h.
Referenced by time_to_tm().
#define EPOCH_YEAR 1970 /*< Thursday Jan 1 1970 */ |
Definition at line 29 of file time.h.
Referenced by time_to_tm(), timetests(), and tm2epoch().
Convert tm_t *t structure into POSIX asctime() ASCII string.
[in] | t | struct tm * time input. |
Definition at line 394 of file time.c.
Referenced by display_clock(), get_date(), and ntp_setup().
Convert tm_t *t structure into POSIX asctime() ASCII string *buf.
[in] | t | tm_t structure pointer. |
[out] | buf | user buffer for POSIX asctime() string result.
|
Definition at line 367 of file time.c.
Referenced by asctime(), ctime(), ctime_gm(), ctime_r(), and timetests().
Set system clock with seconds and microseconds.
Convert local time_t *t epoch time into POSIX asctime() string buf[].
[in] | tp | time_t * time input. |
Definition at line 424 of file time.c.
Referenced by ntp_setup(), print_dst(), user_loop(), and user_tests().
GMT version of POSIX ctime().
[in] | tp | time_t * time input. |
Definition at line 441 of file time.c.
Referenced by mctime(), ntp_setup(), and print_dst_gmt().
MEMSPACE int Days_Per_Month | ( | int | month, |
int | year | ||
) |
days in a month
[in] | month; | month of year |
[in] | year; | year |
Definition at line 223 of file time.c.
Referenced by normalize(), and tm2epoch().
MEMSPACE void display_clock | ( | void | ) |
Display system time and optionally RTC time.
Definition at line 1227 of file time.c.
Referenced by user_tests().
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.
[in] | dst | 0 .. 1 DST needs to be applied to the arguments for DST caluclulations |
[in] | epoch | 0 | epoch if non-zero - UTC epoch time used to obtain year of DST calculations |
[in] | year | 0 | year if non-zero - UTC year of DST calcululation, if year and epoch are used - ignore epoch |
[in] | month | 0 .. 11, local time month DST transition |
[in] | weekno | 1 .. 4 localtime dayno count in this month |
[in] | dayno | 0 .. 6, localtime day of DST transition, 0 = Sunday |
[in] | hour | 0 .. 23 local time hour of DST transition result is in epoch GMT seconds Example: Eastern Time and Daylight Savings time time_t epoch,start,end; tv_t tv; tv_t tz; gettimeofday(&tv, &tz); epoch = tv.tv_sec; // DST start for this year, 2nd Sunday of Mar at 2:00am EST start = find_dst(0, epoch, 0, 3, 2, 0, 2); // DST start on 2016, 2nd Sunday of Mar at 2:00am EST start = find_dst(0, 0, 2016, 3, 2, 0, 2); // DST ends on for this year, 1st Sunday of Nov at 2:00am DST end = find_dst(1, epoch, 0, 11, 1, 0, 2); // DST ends on 2016, 1st Sunday of Nov at 2:00am DST end = find_dst(1, 0, 2016, 11, 1, 0, 2); |
Definition at line 1038 of file time.c.
Referenced by set_dst().
MEMSPACE int finddayofweek | ( | int | year, |
int | month, | ||
int | day | ||
) |
Get current time struct timeval *tv and struct timezone *tz - POSIX function. We assume a GMT hardware clock.
[in] | tv | time. |
[in] | tz | timezone. |
Definition at line 822 of file time.c.
Referenced by find_dst(), set_dst(), and timetests().
Get current timezone in struct timezone *tz - POSIX function.
[out] | tz | timezone result. |
Definition at line 792 of file time.c.
Referenced by gettimeofday(), localtime_r(), and normalize().
Convert epoch GMT time_t *tp into POSIX static tm_t *t.
[in] | tp | time_t * time input. |
Definition at line 471 of file time.c.
Referenced by display_clock(), ntp_setup(), rtc_init(), and unix_time_to_fat().
Convert epoch GMT time_t *tp into POSIX tm_t *result.
[in] | tp | time_t * time input. |
[out] | result | tm_t *result. |
Definition at line 456 of file time.c.
Referenced by ctime_gm(), and gmtime().
MEMSPACE void initialize_clock | ( | int | minwest | ) |
initialize system time - if we have an RTC use it
[in] | minwest | your time zone as minute west |
Definition at line 1178 of file time.c.
Referenced by setup().
Test GMT epoch time to see if DST applies in a local timezone.
[in] | epoch | seconds in GMT normalize() return 1 if yes, 0 if not |
Definition at line 1147 of file time.c.
Referenced by localtime_r(), and normalize().
Convert POSIX epoch time_t *tp into POSIX tm_t *result.
[in] | tp | time_t * epoch time input. |
Definition at line 522 of file time.c.
Referenced by ctime(), ctime_r(), get_date(), and get_fattime().
Convert POSIX epoch time_t *tp into POSIX tm_t *result expressed as local time using timezone and DST corrections.
[in] | t | time_t * epoch time input. |
[out] | result | tm_t *result. |
Definition at line 499 of file time.c.
Referenced by localtime(), and timetests().
convert tm_t structure to time_t local time epoch
[in] | t | tm_t time input. |
Definition at line 534 of file time.c.
Referenced by ntp_setup(), and timetests().
Normalize POSIX tm_t *t struct and convert to epoch time Note: does not deal with DST - by design.
[in] | t | tm_t time input. |
[in] | normalize_to_timezone | nonzero = adjust to local timezone and DST |
Definition at line 654 of file time.c.
Referenced by asctime_r(), mktime(), and timegm().
MEMSPACE void print_dst | ( | void | ) |
print start/stop for DST as localtime for this year
Definition at line 1158 of file time.c.
Referenced by ntp_setup().
MEMSPACE void print_dst_gmt | ( | void | ) |
print start/stop for DST as GMT for this year
Definition at line 1166 of file time.c.
Referenced by ntp_setup().
Set DST start and end time for the given epoch year.
[in] | 0 | - or epoch seconds in GMT used to determin the year to aply DST in If 0 we get local GMT epoch time in seconds |
Definition at line 1113 of file time.c.
Referenced by is_dst(), and ntp_setup().
MEMSPACE int setdate | ( | void | ) |
MEMSPACE int setdate_r | ( | char * | buf | ) |
Set date and time from string in this format "YYYY MM DD HH:MM:SS".
[in] | buf | Date string in this format "YYYY MM DD HH:MM:SS". |
Definition at line 919 of file time.c.
Referenced by setdate(), and user_tests().
Set current time struct timeval *tv and struct timezone *tz - POSIX function. We assume a GMT hardware clock.
[in] | tv | time. |
[in] | tz | timezone. |
Definition at line 861 of file time.c.
Referenced by ntp_setup().
Set current timezone with struct timezone *tz - POSIX function.
[in] | tz | timezone result. |
Definition at line 806 of file time.c.
Referenced by initialize_clock(), and settimeofday().
Return second from epoch - POSIX function.
[in,out] | t | pointer to store time in.
|
Definition at line 843 of file time.c.
Referenced by get_date(), get_fattime(), setup(), user_loop(), user_tests(), and utime().
Converts epoch ( seconds from 1 Jan EPOCH_YEAR UTC), offset seconds, to UNIX tm *t.
[in] | epoch | Seconds elapsed since January 1, EPOCH_YEAR.
|
[in] | offset | Offset in seconds to localtime.
|
[out] | t | Unix tm struct pointer output. |
Definition at line 262 of file time.c.
Referenced by find_dst(), gmtime_r(), localtime_r(), and normalize().
Convert tm_t structure as GMT time into GMT seconds since 1900. All calculactions are in GMT regardless of timezoe settings.
Definition at line 347 of file time.c.
Referenced by display_clock(), fat_time_to_unix(), find_dst(), initialize_clock(), and setdate_r().
MEMSPACE char* tm_mon_to_ascii | ( | int | i | ) |
Get string Short name of Month from month number.
[in] | i | Month 0 .. 11 to string. |
MEMSPACE char* tm_wday_to_ascii | ( | int | i | ) |