Skip to main content

Module datetime

Module datetime 

Source
Expand description

datetime submodule. Date/time utilities — port of Src/Modules/datetime.c.

C source has 0 structs/enums. Rust port matches: 0 types. Functions:

  • getcurrentsecs [c:206]
  • getcurrentrealtime [c:212]
  • getcurrenttime [c:220]
  • reverse_strftime [c:42]
  • output_strftime [c:99] (the actual builtin entry)
  • bin_strftime [c:187] (TZ-scope wrapper around output_strftime)
  • 6 module loaders

C uses libc localtime(3) + zsh’s custom ztrftime() (which extends POSIX strftime with the %.N nanosecond syntax). The Rust port calls crate::ported::utils::ztrftime() for the base format and adds %N extensions on top.

Functions§

bin_strftime
Port of bin_strftime(char *nam, char **argv, Options ops, int func) from Src/Modules/datetime.c:187. The strftime builtin entry — wraps output_strftime in a local param-scope that copies $TZ so output_strftime’s localtime(3) calls see the user’s timezone even if a function scope has shadowed it.
boot_
Port of boot_(UNUSED(Module m)) from Src/Modules/datetime.c:292.
cleanup_
Port of cleanup_(UNUSED(Module m)) from Src/Modules/datetime.c:299. C body: return setfeatureenables(m, &module_features, NULL);
enables_
Port of enables_(UNUSED(Module m), UNUSED(int **enables)) from Src/Modules/datetime.c:285. C body: return handlefeatures(m, &module_features, enables);
features_
Port of features_(UNUSED(Module m), UNUSED(char ***features)) from Src/Modules/datetime.c:277. C body: *features = featuresarray(m, &module_features); return 0;
finish_
Port of finish_(UNUSED(Module m)) from Src/Modules/datetime.c:306.
getcurrentrealtime
Port of getcurrentrealtime(UNUSED(Param pm)) from Src/Modules/datetime.c:212. Returns the current high-resolution epoch time as f64 — backs $EPOCHREALTIME.
getcurrentsecs
Port of getcurrentsecs(UNUSED(Param pm)) from Src/Modules/datetime.c:206. Returns the current epoch seconds — backs $EPOCHSECONDS. C body: return (zlong) time(NULL); WARNING: param names don’t match C — Rust=() vs C=(pm)
getcurrenttime
Port of getcurrenttime(UNUSED(Param pm)) from Src/Modules/datetime.c:220. Returns the current epoch as (secs, nanos) — backs the $epochtime two-element array param.
output_strftime
Port of output_strftime(char *nam, char **argv, Options ops, UNUSED(int func)) from Src/Modules/datetime.c:99. The output_strftime builtin entry. Parses argv (format, timestamp, nanoseconds), calls localtime(3) to convert, formats via ztrftime() with retry-on-overflow, then writes the result to stdout (or setsparam to the -s NAME scalar).
reverse_strftime
Port of reverse_strftime(char *nam, char **argv, char *scalar, int quiet) from Src/Modules/datetime.c:42. Parses a time string per the format string and assigns the resulting epoch seconds to scalar (or stdout if NULL).
setup_
Port of setup_(UNUSED(Module m)) from Src/Modules/datetime.c:270.