tm.h¶
Utility library for struct tm.
-
TM_WDAY_SUN¶ Sunday in
struct tm::tm_wday.1
(0)
-
TM_WDAY_MON¶ Monday in
struct tm::tm_wday.1
(1)
-
TM_WDAY_TUE¶ Tuesday in
struct tm::tm_wday.1
(2)
-
TM_WDAY_WED¶ Wednesday in
struct tm::tm_wday.1
(3)
-
TM_WDAY_THU¶ Thursday in
struct tm::tm_wday.1
(4)
-
TM_WDAY_FRI¶ Friday in
struct tm::tm_wday.1
(5)
-
TM_WDAY_SAT¶ Saturday in
struct tm::tm_wday.1
(6)
-
TM_MON_JAN¶ January in
struct tm::tm_mon1
( 0)
-
TM_MON_FEB¶ February in
struct tm::tm_mon1
( 1)
-
TM_MON_MAR¶ March in
struct tm::tm_mon1
( 2)
-
TM_MON_APR¶ April in
struct tm::tm_mon1
( 3)
-
TM_MON_MAY¶ May in
struct tm::tm_mon1
( 4)
-
TM_MON_JUN¶ June in
struct tm::tm_mon1
( 5)
-
TM_MON_JUL¶ July in
struct tm::tm_mon1
( 6)
-
TM_MON_AUG¶ August in
struct tm::tm_mon1
( 7)
-
TM_MON_SEP¶ September in
struct tm::tm_mon1
( 8)
-
TM_MON_OCT¶ October in
struct tm::tm_mon1
( 9)
-
TM_MON_NOV¶ November in
struct tm::tm_mon1
(10)
-
TM_MON_DEC¶ December in
struct tm::tm_mon1
(11)
-
const int8_t
TM_MON_DAYS()¶ The number of days in common years.
See also
-
const int16_t
TM_MON_DAYS_ACCU()¶ The prefixsum of the number of days in common years.
See also
-
int
tm_is_leap_year(unsigned year)¶ Tells if a given year is a leap year in the Gregorian calendar.
Parameters
year: The year. Probably should be ≥ 1582, but needs to be ≥ 1. Return values
1if it is a leap year,0if it is a common year.
-
int
tm_doomsday(int year)¶ Returns the congruent weekday of the Doomsday (March 0).
Only applies for years in the Gregorian calendar.
Parameters
year: The year. Probably should be ≥ 1582, but needs to be ≥ 1. Return values
- The result
% 7is the weekday of the Doomsday of the given year.
- The result
-
void
tm_get_wyday(int year, int mon, int mday, int * wday, int * yday)¶ Calculates the day of the year and the weekday of a given date.
Illegal dates are not catched.
Parameters
year: The year. Probably should be ≥ 1582, but needs to be ≥ 1. mon: The month, TM_MON_JAN to TM_MON_DEC. mday: The day in the month, 1 to 31. wday: Returns the day of the week. yday: Returns the day of the year (Jan 1st is 0).
-
void
tm_fill_derived_values(struct tm * tm)¶ Fills in
struct tm::tm_wdayandstruct tm::tm_ydaygiven a date.struct tm::tm_year,struct tm::tm_mon, andstruct tm::tm_mdayneed to be set before you call this function.Parameters
tm: The datum to operate on.
-
int
tm_is_valid_date(int year, int mon, int mday)¶ Tests if a date is valid.
Dates before 1582-10-15 are invalid.
Parameters
year: The year. mon: The month. mday: The day in the month. Return values
- 0 iff the date is invalid.
-
int
tm_is_valid_time(int hour, int min, int sec)¶ Shallow test if a time is valid.
This function accepts leap seconds at any given time, because the timezone is unknown.
Parameters
hour: The hour. min: The minutes. sec: The seconds. Return values
- 0 iff the time is invalid.