Reference

Useful Durations

DAY

A day in seconds.


HOUR

An hour in seconds.


MINUTE

A minute in seconds.


WEEK

A week in seconds.


Current Time Functions

time_t dt_now()

Return the current (UTC) date and time.

Return
Seconds since the epoch (01-01-1974 00:00:00 UTC).


time_t dt_today()

Return the current (UTC) date.

Return
Seconds since the epoch (01-01-1974 00:00:00 UTC) at midnight today.


Formatting and Conversion

time_t dt_parse_date(const char *date)

Parse a date.

Remark
The value returned represents midnight (UTC) on the date passed in.
Return
Seconds since the epoch (01-01-1974 00:00:00 UTC).
Parameters
  • date: The date to parse. Currently only medium date is supported (EG 03-Apr-2018).


char *dt_short_month_str(int month)

Look up a short month string for the given month number.

Return
A NULL terminated string representing the month number.
Remark
The result is lower case. The month number is one based, so 1 returns ‘jan’, 2 returns ‘feb’, etc.
Parameters
  • month: (one based).


char *dt_timestamp_str(MEM_SCOPE mem, time_t t, int utc)

Return a standard timestamp string.

Return
A NULL terminated string as a formatted timestamp. EG 01-Jan-2019 13:46:29.
Remark
Using FALSE for utc will adjust the time in accordance with the host system date/time timezone and daylight savings settings.
Parameters
  • mem: A MEM_SCOPE to own the returned string.
  • t: The (UTC) time to format as a timestamp as seconds since the epoch (01-01-1974 00:00:00 UTC).
  • utc: FALSE to format as local time, TRUE to format as UTC time.