std/datetime
Date and time from epoch timestamps. Construct with a DateTime static; format with a method.
milo
from "std/datetime" import { DateTime, weekdayName, monthName }Types
DateTime
milo
struct DateTime {
year: i32,
month: i32,
day: i32,
hour: i32,
minute: i32,
second: i32,
weekday: i32,
}A broken-down calendar date and time.
Constructors (statics)
DateTime.now
milo
fn DateTime.now(): DateTimeCurrent UTC date and time.
DateTime.localNow
milo
fn DateTime.localNow(): DateTimeCurrent date and time in the local timezone.
DateTime.fromEpoch
milo
fn DateTime.fromEpoch(epochSec: i64): DateTimeUTC DateTime for a Unix epoch timestamp (seconds).
DateTime.fromEpochLocal
milo
fn DateTime.fromEpochLocal(epochSec: i64): DateTimeLocal DateTime for a Unix epoch timestamp (seconds).
Formatting (methods)
dt.format
milo
fn format(self: &DateTime): stringFull date-time string (e.g. "2026-05-15 10:30:00").
dt.formatDate
milo
fn formatDate(self: &DateTime): stringDate portion only (e.g. "2026-05-15").
dt.formatTime
milo
fn formatTime(self: &DateTime): stringTime portion only (e.g. "10:30:00").
Functions
weekdayName
milo
fn weekdayName(weekday: i32): stringEnglish name for a weekday (0 = Sunday).
monthName
milo
fn monthName(month: i32): stringEnglish name for a month (1 = January).
Example
milo
let dt = DateTime.now()
print(dt.format())
print(weekdayName(dt.weekday) + ", " + monthName(dt.month))