Skip to content

time and date — date and time ​

mzs
include time
include date

INFO

Available in bot scripts. The clock there is in UTC; for Moscow time, .in_time_zone("Europe/Moscow").

In the terminal the modules need a clock: mzs --time script.mzs. Without the flag, include time is an error.

FunctionWhat it does
time.nowthe current moment
time.parse(s)a string → a time; the format is guessed
time.parse(s, layout)a string → a time by a layout ("%d %B %Y")
time.at(unix)Unix seconds → a time
time.mono()seconds of a monotonic clock, a float, for measuring
date.todaytoday, 00:00
date.parse(s)time.parse truncated to midnight
Time methodWhat it does
t.year t.month t.day t.hour t.min t.secfields, int
t.wday, t.ydayday of the week (Sunday is 0), day of the year
t.to_datethe same day, 00:00
t.int, t.msUnix seconds and milliseconds
t.strRFC 3339
t.strftime(layout)formatting
t.in_time_zone(tz)the same moment in another zone
n.seconds n.minutes n.hours n.days n.weeksa duration in seconds, int

Parsing ​

mzs
include time
time.parse("2026-03-05 14:30")  # → 2026-03-05T14:30:00Z
time.parse("05.03.2026")  # → 2026-03-05T00:00:00Z
time.parse("2026-03-05T14:30:00+03:00")  # → 2026-03-05T14:30:00+03:00
time.parse("05 March 2026", "%d %B %Y")  # → 2026-03-05T00:00:00Z
time.at(1772721015)  # → 2026-03-05T14:30:15Z
try time.parse("yesterday") else (e) -> e["kind"]  # → "argument"

Dates with dots and slashes are read day first.

Fields and format ​

mzs
include time
t = time.parse("2026-03-05 14:30:15")
[t.year, t.month, t.day, t.hour, t.min, t.sec]  # → [2026,3,5,14,30,15]
t.wday  # → 4
t.int  # → 1772721015
t.strftime("%d.%m.%Y %H:%M")  # → "05.03.2026 14:30"
t.strftime("%-d %B, %A")  # → "5 March, Thursday"
%Y year%y year, 2 digits%m month%d day
%H hour%M minute%S second%j day of the year
%a Thu%A Thursday%b Mar%B March
%p AM/PM%z +0300%Z MSK%% a % sign
%s Unix seconds%L milliseconds%f microseconds%-d, %-m no leading zero

Month and day names are English only. An unknown directive is an error.

Arithmetic ​

A duration is whole seconds: time + int, time - time.

mzs
include time
t = time.parse("2026-03-05 14:30")
(t + 90.minutes).strftime("%H:%M")  # → "16:00"
(t - 2.hours).strftime("%H:%M")  # → "12:30"
(t + 1.weeks).strftime("%d.%m")  # → "12.03"
time.parse("2026-03-06") - time.parse("2026-03-05")  # → 86400
(time.parse("2026-03-10") - time.parse("2026-03-05")) / 1.days  # → 5
t < t + 1  # → true

Time zones ​

mzs
include time
t = time.parse("2026-03-05 14:30")
t.in_time_zone("Europe/Moscow").strftime("%H:%M %Z")  # → "17:30 MSK"
t.in_time_zone("Europe/Moscow") == t  # → true

Dates ​

mzs
include date
date.parse("2026-03-05 14:30")  # → 2026-03-05T00:00:00Z
type(date.today)  # → "time"

Schedule ​

mzs
include time
start = time.parse("2026-03-05 09:00")
(0..<3).each { (i) ->
  s = start + (i * 45).minutes
  println("${s.strftime("%H:%M")}–${(s + 45.minutes).strftime("%H:%M")}")
}
text
09:00–09:45
09:45–10:30
10:30–11:15

Measuring time ​

mzs
include time
t0 = time.mono()
(1..100000).sum
took = time.mono() - t0
took >= 0  # → true