API overview - FObersteiner/zdt GitHub Wiki
Datetime
Input: Make a Datetime
Now:
zdt.Datetime.now
- with an optional time zone or UTC offset (seetz_options
).zdt.Datetime.nowUTC
- a fail-safe shortcut to get UTC datetime.
From fields:
zdt.Datetime.fromFields
- year, month, day etc.; see alsozdt.Datetime.Fields
struct.
From a string:
zdt.Datetime.fromString
- see parsing directives.zdt.Datetime.fromISO8601
- shortcut to parse ISO8601-compatible input formats.
From Unix time:
zdt.Datetime.fromUnix
- must specify a resolution (seconds, microseconds etc.) for the input quantity; see alsozdt.Duration.Resolution
. Optional time zone or UTC offset.
Output: Datetime to something else
To string:
zdt.Datetime.toString
- see formatting directives. Can either be called as a library function (zdt.Datetime.toString
) or as a method of a datetime instancedt
;dt.toString
.
To Unix time:
zdt.Datetime.toUnix
- a resolution must be specified, seefromUnix
. Also to be called either as a library function or instance method.
To ISO calendar:
Duration
Input: Make a Duration
ISO8601 duration string, absolute:
From anzdt.Duration.fromISO8601
- note: since the Duration type represents an absolute difference in time, years and months are not allowed (seeRelativeDelta
).
From an ISO8601 duration string, relative timespan ("wall-time"):
zdt.Duration.RelativeDelta.fromISO8601
- might include years and months.
From multiples of a timespan:
Output: Duration to something else
To multiple of a timespan:
Total seconds:
Timezone
From embedded tz database:
From system tz database:
zdt.Timezone.fromSystemTzdata
. See also:prefix_tzdb
option from build.zig -Timezone.tzdb_prefix
can be used as db_path.zdt.Timezone.tzLocal
- try to obtain the local time zone from the system.