World all
API localtime struct timezone string dd(u8 1-31) mm(u8 1-12) yy (s16 -32677 - +32767) hh(u8 0-11) mm(u8 0-59) ss(u8 0-59) Get localized time (optional secs since 1970 UTC time) (optional timezone string) localtime to UTC time
- Imports:
- interface
wasi:clocks/wall-clock@0.2.0
- interface
hermes:localtime/api
- interface
Import interface wasi:clocks/wall-clock@0.2.0
WASI Wall Clock is a clock API intended to let users query the current time. The name "wall" makes an analogy to a "clock on the wall", which is not necessarily monotonic as it may be reset.
It is intended to be portable at least between Unix-family platforms and Windows.
A wall clock is a clock which measures the date and time according to some external reference.
External references may be reset, so this clock is not necessarily monotonic, making it unsuitable for measuring elapsed time.
It is intended for reporting the current date and time for humans.
Types
record datetime
A time and date in seconds plus nanoseconds.
Record Fields
Functions
now: func
Read the current value of the clock.
This clock is not monotonic, therefore calling this function repeatedly will not necessarily produce a sequence of non-decreasing values.
The returned timestamps represent the number of seconds since 1970-01-01T00:00:00Z, also known as POSIX's Seconds Since the Epoch, also known as Unix Time.
The nanoseconds field of the output is always less than 1000000000.
Return values
resolution: func
Query the resolution of the clock.
The nanoseconds field of the output is always less than 1000000000.
Return values
Import interface hermes:localtime/api
Localtime API
Localtime API functionality exposed to the Hermes WASM Modules.
Permissions
This API is ALWAYS available. Logging API Interface
Types
type datetime
The timezone we are localized for.
record localtime
Time in localtime format.
Record Fields
-
Year
-
Month (0-11)
-
Day of week (0-6)
-
Day (1-31)
-
Hour (0-23)
-
Minute (0-59)
-
Second (0-59)
-
tz
:timezone
Nanoseconds
enum errno
Errors that can occur converting times
Enum Cases
Functions
get-localtime: func
Get localtime from a datetime or now.
Parameters
when
: The datetime we want to convert (Optional, if not set it will convert now
).
tz
: The timezone to use. (Optional, if not set uses the local machines configured local timezone.)
Returns
localtime
: the converted time.
errno
: An error indicating why conversion failed.
Params
Return values
alt-localtime: func
Get a new localtime from a localtime, by recalculating time for a new timezone.
Parameters
time
: The localtime to convert.
tz
: The timezone to use. (Optional, if not set uses the local machines configured local timezone.)
Returns
localtime
: the converted time.
errno
: An error indicating why conversion failed.
Params
Return values
get-datetime: func
Get a datetime from a localtime.
Parameters
time
: The localtime to convert.
Returns
datetime
: the converted time.
errno
: An error indicating why conversion failed.
Params
time
:localtime