time manipulation functions in Pure mksh™
POSIX (i.e. no leap second support and Y2038 problem)
available definitions:
• tm_* constants (offset of "struct tm" members in indexed array)
• mirtime_months, mirtime_wdays (mapping to strings in the "C" locale)
available functions:
• timet2mjd ${posix_timet_seconds}
⇒ ${mjd_day} ${mjd_sec}
• mjd2timet ${mjd_day} ${mjd_sec}
⇒ ${posix_timet_seconds}
• mjd_explode ${mjd_day} ${mjd_sec}
⇒ ${struct_tm[@]}
• mjd_implode ${struct_tm[@]}
⇒ ${mjd_day} ${mjd_sec}
The functions all currently share that they take and output
an array (mirtime_mjd or struct tm) in split form, i.e. one
function argument per struct member, and space-separated output.
(This works with this data.)
Not all members of struct tm are used:
When emitting a struct tm (by mjd_explode), these are hardcoded:
• tm_isdst = 0
• tm_gmtoff = 0
• tm_zone = "UTC"
When parsing a struct tm (by mjd_implode), these are ignored:
• tm_wday, tm_yday (only tm_mon+tm_mday are used)
• tm_isdst (only tm_gmtoff is used as additional offset)
• tm_zone (it's a descriptive string anyway)
This matches behaviour of the mirtime functions in MirBSD libkern
(kernel, bootloader, libc), except that no leap second information
is available, and mksh_ari_t (32 bit) is used instead of time_t.