Mstdlib-1.24.0
Date Time

Functions

M_time_t M_time (void)
 
M_bool M_time_gettimeofday (M_timeval_t *tv)
 
int M_time_days_in_month (M_int64 year, M_int64 month)
 
M_bool M_time_is_valid_day (M_int64 year, M_int64 month, M_int64 day)
 
void M_time_normalize_tm (struct M_time_tm *tm)
 
M_time_t M_time_fromlocal (M_time_localtm_t *ltime, const M_time_tz_t *tz)
 
void M_time_tolocal (M_time_t t, M_time_localtm_t *ltime, const M_time_tz_t *tz)
 
void M_time_togm (M_time_t t, M_time_gmtm_t *tm)
 
M_time_t M_time_fromgm (M_time_gmtm_t *tm)
 

Detailed Description

Function Documentation

◆ M_time()

M_time_t M_time ( void  )

Get the system time.

While M_time_t is guaranteed to be 64 bit the time returned is not. Time is dependent on the platform and some only support 32 bit time values. On these systems M_time will only return a value up to Jan 19, 2038 03:14:07 UTC.

Returns
Number of seconds since Epoch (Jan 1, 1970 00:00:00 UTC).

◆ M_time_gettimeofday()

M_bool M_time_gettimeofday ( M_timeval_t tv)

Get the number of seconds and milliseconds since Epoch.

Parameters
[out]tvThe time as seconds and milliseconds since Epoch.
Returns
M_TRUE on success, otherwise M_FALSE.

◆ M_time_days_in_month()

int M_time_days_in_month ( M_int64  year,
M_int64  month 
)

Get the number of days in a given month for a given year.

Accounts for leap years.

Parameters
[in]yearThe year.
[in]monthThe month. 1-12.
Returns
The number of days in the month.

◆ M_time_is_valid_day()

M_bool M_time_is_valid_day ( M_int64  year,
M_int64  month,
M_int64  day 
)

Determine if a give day of month valid for the given month for a given year.

Parameters
[in]yearThe year.
[in]monthThe month.
[in]dayThe day of month.
Returns
M_TRUE if the day is valid. Otherwise M_FALSE.

◆ M_time_normalize_tm()

void M_time_normalize_tm ( struct M_time_tm tm)

Normalize a struct tm.

If adjustments are made to a struct tm this will bring the adjustments back to a real date/time.

This does not modify the isdst, gmtoff or abbr fields of the struct. These may be wrong if the adjust time crosses a DST boundary for example. Use M_time_fromlocal with the appropriate time zone data (or NULL if using the systems current info) to normalize a time taking into account these fields. Or use M_time_fromgm if dealing with a gm time (isdst, gmtoff and abbr will be cleared).

Parameters
[in,out]tmThe tm to normalize.

◆ M_time_fromlocal()

M_time_t M_time_fromlocal ( M_time_localtm_t *  ltime,
const M_time_tz_t tz 
)

Convert a local time to a UTC time.

Parameters
[in,out]ltimeThe local time structure to convert. This will be normalized.
[in]tzThe time zone the local time is in.
Returns
UTC time.

◆ M_time_tolocal()

void M_time_tolocal ( M_time_t  t,
M_time_localtm_t *  ltime,
const M_time_tz_t tz 
)

Convert a UTC time to a local time struct.

Parameters
[in]tThe UTC time.
[out]ltimeThe local time struct.
[in]tzThe time zone the local time is in.

◆ M_time_togm()

void M_time_togm ( M_time_t  t,
M_time_gmtm_t *  tm 
)

Convert a UTC time to a broken out time struct.

Parameters
[in]tUTC time.
[out]tmTime struct.

◆ M_time_fromgm()

M_time_t M_time_fromgm ( M_time_gmtm_t *  tm)

Convert a broken out time struct to a unix timestamp.

Parameters
[in,out]tmThe time struct. This will be normalized.
Returns
Time stamp.