mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 14:57:18 +00:00
37 lines
819 B
Plaintext
37 lines
819 B
Plaintext
// time.vr — date/time helpers (part of the VuurRaaf stdlib).
|
|
//
|
|
// import time
|
|
// println(time.format(time.now(), "YYYY-MM-DD HH:mm:ss"))
|
|
// println(time.format(time.now(), "YYYY-MM-DD"))
|
|
//
|
|
// Tokens follow the Moment.js style: YYYY (year), MM (month), DD (day),
|
|
// HH (24h hour), mm (minute), ss (second), plus literals like "-", ":".
|
|
// All values are Unix epoch seconds. `time.parse` accepts common ISO
|
|
// timestamps like "2026-08-25 14:03:22".
|
|
|
|
fn now() {
|
|
return now()
|
|
}
|
|
|
|
fn ms() {
|
|
return time_ms()
|
|
}
|
|
|
|
fn format(t, spec) {
|
|
return format_time(t, spec)
|
|
}
|
|
|
|
fn parse(s) {
|
|
return parse_time(s)
|
|
}
|
|
|
|
// date(t) formats just the calendar day: YYYY-MM-DD.
|
|
fn date(t) {
|
|
return format_time(t, "YYYY-MM-DD")
|
|
}
|
|
|
|
// clock(t) formats just the wall clock: HH:mm:ss.
|
|
fn clock(t) {
|
|
return format_time(t, "HH:mm:ss")
|
|
}
|