Provides the std time package.
Package: std.time
Reachable from entry: no
std/fmt.mlasfmt→ std/fmt.mlstd/string.mlass→ std/string.ml
namespace clockTime-of-day construction, formatting and arithmetic.
Source: std/time.ml:685
function addMillis(t, delta)Add milliseconds to a time (wraps within 24h).
| Parameter | Type | Default | Description |
|---|---|---|---|
t |
dynamic |
— | Value supplied for t. |
delta |
dynamic |
— | Value supplied for delta. |
Source: std/time.ml:755
function compare(a, b)Compare two times.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/time.ml:711
function fromMillis(ms)Convert milliseconds since 00:00 into a Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
ms |
dynamic |
— | Value supplied for ms. |
Source: std/time.ml:734
function isValid(t)Validate a Time struct.
| Parameter | Type | Default | Description |
|---|---|---|---|
t |
dynamic |
— | Value supplied for t. |
Source: std/time.ml:704
function isValidHMSM(h, m, s0, ms)Validate a time quadruple (hour, minute, second, millisecond).
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
dynamic |
— | Value supplied for h. |
m |
dynamic |
— | Value supplied for m. |
s0 |
dynamic |
— | Value supplied for s0. |
ms |
dynamic |
— | Value supplied for ms. |
Source: std/time.ml:691
function parse(text)Parse time in the form HH:MM or HH:MM:SS[.mmm].
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
dynamic |
— | Text to process. |
Source: std/time.ml:784
function toMillis(t)Convert a Time into milliseconds since 00:00:00.000.
| Parameter | Type | Default | Description |
|---|---|---|---|
t |
dynamic |
— | Value supplied for t. |
Source: std/time.ml:725
function toString(t)Format time as HH:MM:SS.mmm.
| Parameter | Type | Default | Description |
|---|---|---|---|
t |
dynamic |
— | Value supplied for t. |
Source: std/time.ml:775
function clockToString(t)Format a Time as a string (HH:MM:SS.mmm).
| Parameter | Type | Default | Description |
|---|---|---|---|
t |
dynamic |
— | Value supplied for t. |
Source: std/time.ml:1103
namespace dateCalendar-date construction, validation and arithmetic.
Source: std/time.ml:443
- std.time.Date — struct
function addDays(d, delta)Add days to a date.
| Parameter | Type | Default | Description |
|---|---|---|---|
d |
dynamic |
— | Value supplied for d. |
delta |
dynamic |
— | Value supplied for delta. |
Source: std/time.ml:610
function compare(a, b)Compare two dates.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/time.ml:597
function dayOfWeek(d)Compute day of week for a date.
| Parameter | Type | Default | Description |
|---|---|---|---|
d |
dynamic |
— | Value supplied for d. |
Source: std/time.ml:635
function daysInMonth(year, month)Number of days in a month for a given year.
| Parameter | Type | Default | Description |
|---|---|---|---|
year |
dynamic |
— | Value supplied for year. |
month |
dynamic |
— | Value supplied for month. |
Source: std/time.ml:462
function diffDays(a, b)Difference in days between two dates.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/time.ml:624
function fromOrdinal(days)Inverse of toOrdinal.
| Parameter | Type | Default | Description |
|---|---|---|---|
days |
dynamic |
— | Value supplied for days. |
Source: std/time.ml:542
function isLeapYear(year)Check if a year is a leap year (Gregorian rules).
| Parameter | Type | Default | Description |
|---|---|---|---|
year |
dynamic |
— | Value supplied for year. |
Source: std/time.ml:446
function isValid(d)Validate a Date struct.
| Parameter | Type | Default | Description |
|---|---|---|---|
d |
dynamic |
— | Value supplied for d. |
Source: std/time.ml:509
function isValidYMD(year, month, day)Validate a date triple (year, month, day).
| Parameter | Type | Default | Description |
|---|---|---|---|
year |
dynamic |
— | Value supplied for year. |
month |
dynamic |
— | Value supplied for month. |
day |
dynamic |
— | Value supplied for day. |
Source: std/time.ml:491
function parse(text)Parse a date in the form YYYY-MM-DD.
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
dynamic |
— | Text to process. |
Source: std/time.ml:656
function toOrdinal(d)Convert a Date to an ordinal day count.
| Parameter | Type | Default | Description |
|---|---|---|---|
d |
dynamic |
— | Value supplied for d. |
Source: std/time.ml:515
function toString(d)Format date as YYYY-MM-DD.
| Parameter | Type | Default | Description |
|---|---|---|---|
d |
dynamic |
— | Value supplied for d. |
Source: std/time.ml:647
namespace datetimeCombined local/UTC date-time conversion and arithmetic.
Source: std/time.ml:837
- std.time.DateTime — struct
function addDays(dt, deltaDays)Add whole days to a DateTime (keeps clock time).
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
deltaDays |
dynamic |
— | Value supplied for deltaDays. |
Source: std/time.ml:910
function addMillis(dt, delta)Add milliseconds to a DateTime.
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
delta |
dynamic |
— | Value supplied for delta. |
Source: std/time.ml:876
function compare(a, b)Compare two date-times.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/time.ml:847
function fromSystemTime(st)Convert a native SystemTime value to a DateTime.
| Parameter | Type | Default | Description |
|---|---|---|---|
st |
dynamic |
— | Value supplied for st. |
Source: std/time.ml:969
function fromUnixMillis(unixMs)Convert Unix milliseconds since 1970-01-01T00:00:00Z to a DateTime.
| Parameter | Type | Default | Description |
|---|---|---|---|
unixMs |
dynamic |
— | Value supplied for unixMs. |
Source: std/time.ml:1024
function isValid(dt)Validate a DateTime struct.
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
Source: std/time.ml:840
function nowLocal()Current local wall-clock DateTime.
Source: std/time.ml:1001
function nowUnixMillisUtc()Current Unix milliseconds based on UTC time.
Source: std/time.ml:1051
function nowUtc()Current UTC wall-clock DateTime.
Source: std/time.ml:1007
function parse(text)Parse a DateTime in the form "YYYY-MM-DD HH:MM:SS[.mmm]" (also accepts 'T').
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
dynamic |
— | Text to process. |
Source: std/time.ml:935
function toMillis(dt)Convert a DateTime to milliseconds since 0001-01-01 00:00:00.000.
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
Source: std/time.ml:857
function toString(dt)Format a DateTime as "YYYY-MM-DD HH:MM:SS.mmm".
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
Source: std/time.ml:926
function toUnixMillis(dt)Convert a DateTime to Unix milliseconds since 1970-01-01T00:00:00Z.
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
Source: std/time.ml:1014
function datetimeToString(dt)Format a DateTime as a string (YYYY-MM-DD HH:MM:SS.mmm).
| Parameter | Type | Default | Description |
|---|---|---|---|
dt |
dynamic |
— | Value supplied for dt. |
Source: std/time.ml:1109
function dateToString(d)Format a Date as a string (YYYY-MM-DD).
| Parameter | Type | Default | Description |
|---|---|---|---|
d |
dynamic |
— | Value supplied for d. |
Source: std/time.ml:1097
function elapsed(start_time, end_time)Compute elapsed milliseconds between two tick readings.
| Parameter | Type | Default | Description |
|---|---|---|---|
start_time |
dynamic |
— | Value supplied for start_time. |
end_time |
dynamic |
— | Value supplied for end_time. |
Source: std/time.ml:340
function formatDuration(ms)Format a duration in milliseconds into a readable string.
| Parameter | Type | Default | Description |
|---|---|---|---|
ms |
dynamic |
— | Value supplied for ms. |
Source: std/time.ml:1062
const MAX_PORTABLE_SLEEP_MS = 2147483647Track the max portable sleep ms value used by this standard-library module.
Source: std/time.ml:26
function sleep(ms)Sleep for a number of milliseconds.
| Parameter | Type | Default | Description |
|---|---|---|---|
ms |
dynamic |
— | Value supplied for ms. |
Source: std/time.ml:312
- std.time.SystemTime — struct
const SYSTEMTIME_SIZE = 16SYSTEMTIME decoding helpers (used for WinAPI GetLocalTime/GetSystemTime).
Source: std/time.ml:44
function ticks()Read monotonic milliseconds since system start (no wall-clock).
Source: std/time.ml:305
- std.time.Time — struct
const TIME_ERR = 300Monotonic timing, durations and calendar conversion on Windows and Linux.
Source: std/time.ml:24
const UNIX_EPOCH_ORDINAL = 719162Ordinal day count for 1970-01-01, with 0001-01-01 as day 0.
Source: std/time.ml:383
namespace win32------------------------------------------------------------ Platform-native time helpers. ------------------------------------------------------------
Source: std/time.ml:109
function GetLocalTime()Get local wall-clock time via Win32 GetLocalTime.
Source: std/time.ml:145
function GetSystemTime()Get UTC wall-clock time via Win32 GetSystemTime.
Source: std/time.ml:152
- std.time.win32.SYSTEMTIME — extern_struct