Skip to main content

Module datetime

Module datetime 

Source
Expand description

Datetime arithmetic helpers: UTC timestamp ↔ civil calendar conversion, formatting, parsing.

Functions§

civil_from_days
Converts a day count since the Unix epoch to a proleptic Gregorian date. Returns (year, month, day) where month and day are 1-based.
civil_to_timestamp
Assembles a Unix timestamp (seconds) from calendar components.
days_from_civil
Converts a proleptic Gregorian date (y, m, d) to a day count since the Unix epoch. Month is 1-based; day is 1-based.
format_datestr
Formats a Unix timestamp using a pattern string. Supported tokens: yyyy, MMM (abbreviated month name), MM, dd, HH, mm, ss, SSS.
format_datetime
Formats a Unix timestamp as yyyy-MM-dd HH:mm:ss.
format_duration
Formats a duration in seconds as HH:MM:SS or Nd HH:MM:SS. Adds .mmm suffix when sub-second precision is present.
from_datenum
Converts a MATLAB serial date number to a Unix timestamp.
now_timestamp
Returns the current UTC time as a Unix timestamp.
parse_iso8601
Parses an ISO 8601 date string: yyyy-MM-dd or yyyy-MM-dd HH:mm:ss.
timestamp_to_civil
Decomposes a Unix timestamp (seconds) into calendar components. Returns (year, month, day, hour, minute, second_f64).
to_datenum
Converts a Unix timestamp to a MATLAB serial date number.
today_timestamp
Returns midnight today as a Unix timestamp.