53 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
65 if ( ( tm_year % 4 ) == 0 )
67 if ( ( tm_year % 100 ) == 0 )
69 if ( ( tm_year % 400 ) == 100 )
84 leap_years += ( tm_year / 4 );
85 leap_years -= ( tm_year / 100 );
86 leap_years += ( ( tm_year + 300 ) / 400 );
98static int day_of_week (
int tm_year,
int tm_mon,
int tm_mday ) {
100 { 1, 4, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 };
101 int pseudo_year = tm_year;
106 offset[tm_mon] + tm_mday ) % 7 );
111 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
128 int days_since_epoch;
129 int seconds_since_day;
133 tm_year += ( tm_mon / 12 );
134 tm_mon = ( tm_mon % 12 );
149 tm_wday =
day_of_week ( tm_year, tm_mon, tm_mday );
153 days_since_epoch = ( tm_yday + ( 365 * tm_year ) - 25567 +
156 ( ( ( ( tm_hour * 60 ) + tm_min ) * 60 ) + tm_sec );
158 + seconds_since_day );
160 DBGC ( &
weekdays,
"TIME %04d-%02d-%02d %02d:%02d:%02d => %lld (%s, "
#define assert(condition)
Assert a condition at run-time.
uint16_t offset
Offset to command line.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
int64_t time_t
Seconds since the Epoch.
UINT16_t seconds
Elapsed time.
int tm_mon
Month of year [0,11].
int tm_year
Years since 1900.
int tm_sec
Seconds [0,60].
int tm_yday
Day of year [0,365].
int tm_mday
Day of month [1,31].
int tm_min
Minutes [0,59].
int tm_wday
Day of week [0,6] (Sunday=0).
static const uint16_t days_to_month_start[]
Days from start of year until start of months (in non-leap years).
static int day_of_week(int tm_year, int tm_mon, int tm_mday)
Calculate day of week.
static int leap_years_to_end(int tm_year)
Calculate number of leap years since 1900.
signed long time_offset
Current system clock offset.
static int is_leap_year(int tm_year)
Determine whether or not year is a leap year.
static const char * weekdays[]
Days of week (for debugging).
time_t mktime(struct tm *tm)
Calculate seconds since the Epoch.