Standard library · Time and concurrency

time

The current time, durations, formatting and parsing dates, the monotonic clock, timers and tickers.

import time

There are two kinds of "time" in this package. An instant is a number of seconds since the start of 1970 in UTC, the Unix epoch, and is what you use for dates and clock times. A duration is a span with nanosecond precision, such as "1 hour 30 minutes", which you can add up and compare.

Functions such as Year and FormatDate work in the machine's local time, and their UTC counterparts work in UTC. To measure how long a piece of code took, use the monotonic clock (MonoNanos) rather than Now; the system clock can jump forwards or backwards.

For the Persian and Hijri calendars and for time zones, see the calendar package.

Types

DateTime

struct DateTime
An instant, as seconds since the Unix epoch, the start of 1 January 1970 in UTC.
NameTypeDescription
epochi64 = 0The seconds since the Unix epoch.
time-Local.salam
import time
import str

func main:
    t := time.FromLocalParts(2024, 3, 20, 9, 30, 0)
    println time.Year(t), time.Month(t), time.Day(t), time.Hour(t), time.Minute(t), time.Second(t)
    println time.Weekday(t), time.YearDay(t)
    println time.FormatDate(t), time.FormatTime(t)
    println time.Format(t)
    println time.FormatISO(t)
    r := time.FormatRFC3339(t)
    offset := time.LocalOffsetMinutesAt(t)
    println str.StartsWith(r, "2024-03-20T09:30:00"), (offset == 0) == str.EndsWith(r, "Z")
    dt := time.FromEpoch(t)
    println time.Epoch(dt) == t, dt.epoch == t
    println time.Epoch(time.NowDateTime()) >= t
end
Output2024 3 20 9 30 0 3 80 2024-03-20 09:30:00 2024-03-20 09:30:00 2024-03-20T09:30:00 true true true true true

Duration

struct Duration
A span of time with nanosecond precision; it may be negative.
NameTypeDescription
nsi64 = 0The span in nanoseconds.
time-Duration.salam
import time

func main:
    d := time.Hours(1).add(time.Minutes(30))
    println d.to_str(), d.minutes(), d.secs()
    println time.FormatDuration(time.Milliseconds(1500)), time.FormatDuration(time.Microseconds(250)), time.FormatDuration(time.Nanoseconds(42))
    println time.Seconds(90).to_str(), time.Days(2).hours(), time.SecondsF(0.25).millis()
    p := time.ParseDuration("1h15m30.5s")
    println p.ok, p.value.to_str(), p.value.seconds()
    println time.ParseDuration("ten minutes").ok, time.ParseDurationOr("?", time.Seconds(5)).to_str()
    k := time.Minutes(7)
    println k.sub(time.Minutes(10)).to_str(), k.neg().abs().to_str(), k.neg().is_negative()
    println k.mul(3).to_str(), k.div(2).to_str(), time.Hours(1).ratio(k)
    println k.cmp(time.Seconds(420)), k.less(time.Hours(1)), k.equals(time.Seconds(420))
    t := time.Milliseconds(1750)
    println t.truncate(time.Seconds(1)).to_str(), t.round(time.Seconds(1)).to_str()
    println t.nanos(), t.micros(), t.millis(), time.ZeroDuration().is_zero(), t.days() < 0.001
end
Output1h30m0s 90 5400 1.5s 250us 42ns 1m30s 48 250 true 1h15m30.5s 4530.5 false 5s -3m0s 7m0s true 21m0s 3m30s 8 0 true true 1s 2s 1750000000 1750000 1750 true true

nanos

func nanos(): i64
The span in nanoseconds.

The example for this item is shown with the ones above: time-Duration.salam

micros

func micros(): i64
The span in whole microseconds.

The example for this item is shown with the ones above: time-Duration.salam

millis

func millis(): i64
The span in whole milliseconds.

The example for this item is shown with the ones above: time-Duration.salam

secs

func secs(): i64
The whole seconds, with no fraction.

The example for this item is shown with the ones above: time-Duration.salam

seconds

func seconds(): f64
The span in seconds, with a fraction.

The example for this item is shown with the ones above: time-Duration.salam

minutes

func minutes(): f64
The span in minutes, with a fraction.

The example for this item is shown with the ones above: time-Duration.salam

hours

func hours(): f64
The span in hours, with a fraction.

The example for this item is shown with the ones above: time-Duration.salam

days

func days(): f64
The span in days, with a fraction.

The example for this item is shown with the ones above: time-Duration.salam

add

func add(o: Duration): Duration
The sum of two spans.

The example for this item is shown with the ones above: time-Duration.salam

sub

func sub(o: Duration): Duration
The difference of two spans.

The example for this item is shown with the ones above: time-Duration.salam

mul

func mul(k: i64): Duration
Multiplies the span by a number.

The example for this item is shown with the ones above: time-Duration.salam

div

func div(k: i64): Duration
Divides the span by a number.

The example for this item is shown with the ones above: time-Duration.salam

ratio

func ratio(o: Duration): i64
How many whole times the other span fits in this one, or zero when the other is zero.

The example for this item is shown with the ones above: time-Duration.salam

neg

func neg(): Duration
The span with its sign reversed.

The example for this item is shown with the ones above: time-Duration.salam

abs

func abs(): Duration
The absolute value of the span.

The example for this item is shown with the ones above: time-Duration.salam

is_zero

func is_zero(): bool
True when the span is zero.

The example for this item is shown with the ones above: time-Duration.salam

is_negative

func is_negative(): bool
True when the span is negative.

The example for this item is shown with the ones above: time-Duration.salam

cmp

func cmp(o: Duration): int
Compares with another span: minus one when shorter, zero when equal, one when longer.

The example for this item is shown with the ones above: time-Duration.salam

less

func less(o: Duration): bool
True when it is shorter than the other span.

The example for this item is shown with the ones above: time-Duration.salam

equals

func equals(o: Duration): bool
True when it equals the other span.

The example for this item is shown with the ones above: time-Duration.salam

truncate

func truncate(m: Duration): Duration
Rounds the span down to a multiple of m.

The example for this item is shown with the ones above: time-Duration.salam

round

func round(m: Duration): Duration
Rounds the span to the nearest multiple of m, with halves going away from zero.

The example for this item is shown with the ones above: time-Duration.salam

to_str

func to_str(): str
Writes the span as 1h30m0s; the same as FormatDuration.

The example for this item is shown with the ones above: time-Duration.salam

DurationResult

struct DurationResult
The result of parsing a duration.
NameTypeDescription
okbool = falseWhether the text was read successfully.
valueDurationThe span that was read.

The example for this item is shown with the ones above: time-Duration.salam

TimeResult

struct TimeResult
The result of parsing a date and time.
NameTypeDescription
okbool = falseWhether the text was read successfully.
epochi64 = 0The instant that was read, in seconds since the Unix epoch.
nanosint = 0The fraction of a second, in nanoseconds.
time-UTC.salam
import time

func main:
    t := time.FromUTCParts(2024, 3, 20, 14, 5, 9)
    println t, time.FormatISOUTC(t)
    println time.YearUTC(t), time.MonthUTC(t), time.DayUTC(t), time.HourUTC(t), time.MinuteUTC(t), time.SecondUTC(t)
    println time.FormatHTTPDate(t)
    println time.ParseHTTPDate("Wed, 20 Mar 2024 14:05:09 GMT").epoch == t
    p := time.ParseISO("2024-03-20T17:35:09+03:30")
    println p.ok, p.epoch == t, p.nanos
    println time.ParseISOIn("2024-03-20 17:35:09.25", 210).epoch == t, time.ParseISOIn("2024-03-20 17:35:09.25", 210).nanos
    f := time.ParseFormat("%d/%m/%Y %H:%M %z", "20/03/2024 14:05 +0000")
    println f.ok, time.FormatISOUTC(f.epoch)
    println time.ParseISO("tomorrow").ok, time.ParseISOOr("tomorrow", 0)
    later := time.AddDuration(t, time.Days(10))
    println time.FormatISOUTC(later), time.DiffSeconds(later, t), time.DurationBetween(later, t).to_str()
    println time.SecondsPerMinute, time.SecondsPerHour, time.SecondsPerDay
end
Output1710943509 2024-03-20T14:05:09Z 2024 3 20 14 5 9 Wed, 20 Mar 2024 14:05:09 GMT true true true 0 true 250000000 true 2024-03-20T14:05:00Z false 0 2024-03-30T14:05:09Z 864000 240h0m0s 60 3600 86400

Timer

struct Timer
A one-shot timer: it says whether the span you set has passed.
NameTypeDescription
deadline_nsi64 = 0The end instant on the monotonic clock, in nanoseconds.
activebool = falseWhether the timer is running.
time-Timer.salam
import time

mut count := 0

func main:
    mut timer := time.NewTimer(time.Milliseconds(100))
    println timer.expired(), timer.remaining().millis() > 0
    timer.wait()
    println timer.expired(), timer.remaining().is_zero()
    timer.reset(time.Seconds(10))
    timer.stop()
    println timer.expired(), timer.active
    mut ticker := time.NewTicker(time.Milliseconds(50))
    println ticker.fired()
    ticker.wait()
    time.Sleep(120)
    println ticker.fired(), ticker.dropped >= 1
    ticker.advance()
    println ticker.remaining().millis() <= 100
    ticker.reset(time.Milliseconds(5))
    ticker.stop()
    println ticker.fired()
    time.AfterFunc(time.Milliseconds(10), (): println "after 10 milliseconds" end)
    time.RepeatEvery(time.Milliseconds(5), 2, (): println "tick" end)
    println time.Every(time.Milliseconds(5), (): count += 1 ret count < 3 end)
    count = 0
    println time.WaitUntil((): count += 1 ret count >= 3 end, time.Milliseconds(5), time.Seconds(5))
    println time.WaitUntil((): ret false end, time.Milliseconds(5), time.Milliseconds(20))
end
Outputfalse true true true false false false true true true false after 10 milliseconds tick tick 3 true false

expired

func expired(): bool
True when the timer is running and its span has passed.

The example for this item is shown with the ones above: time-Timer.salam

remaining

func remaining(): Duration
The time left, or zero when it has passed or been stopped.

The example for this item is shown with the ones above: time-Timer.salam

wait

func wait()
Sleeps until the span is over.

The example for this item is shown with the ones above: time-Timer.salam

reset

func reset(d: Duration)
Starts the timer again from now, for a new span.

The example for this item is shown with the ones above: time-Timer.salam

stop

func stop()
Stops the timer; from then on it never expires.

The example for this item is shown with the ones above: time-Timer.salam

Ticker

struct Ticker
A ticker: it "ticks" at a fixed interval.
NameTypeDescription
interval_nsi64 = 0The interval between ticks, in nanoseconds.
next_nsi64 = 0The instant of the next tick.
activebool = falseWhether the ticker is running.
droppedi64 = 0How many ticks were missed because the program came back to the ticker late.

The example for this item is shown with the ones above: time-Timer.salam

fired

func fired(): bool
True when a tick is due, and it moves on to the next one; it does not wait. For loops that have other work to do.

The example for this item is shown with the ones above: time-Timer.salam

wait

func wait()
Sleeps until the next tick.

The example for this item is shown with the ones above: time-Timer.salam

advance

func advance()
Moves the deadline on by one tick, counting and skipping the missed ticks so the ticker does not fall behind.

The example for this item is shown with the ones above: time-Timer.salam

remaining

func remaining(): Duration
The time left until the next tick.

The example for this item is shown with the ones above: time-Timer.salam

reset

func reset(d: Duration)
Changes the interval and starts again from now.

The example for this item is shown with the ones above: time-Timer.salam

stop

func stop()
Stops the ticker.

The example for this item is shown with the ones above: time-Timer.salam

Constants and variables

SecondsPerMinute

const SecondsPerMinute: i32 = 60
The number of seconds in a minute.

The example for this item is shown with the ones above: time-UTC.salam

SecondsPerHour

const SecondsPerHour: i32 = 3600
The number of seconds in an hour.

The example for this item is shown with the ones above: time-UTC.salam

SecondsPerDay

const SecondsPerDay: i32 = 86400
The number of seconds in a day.

The example for this item is shown with the ones above: time-UTC.salam

Functions

Now

func Now(): i64
The current instant in seconds since the Unix epoch.
time-Now.salam
import time

func main:
    start := time.Now()
    a := time.MonoNanos()
    time.Sleep(20)
    time.SleepFor(time.Milliseconds(10))
    b := time.MonoNanos()
    println time.ElapsedMs(a, b) >= 30.0, time.ElapsedUs(a, b) >= 30000.0, time.ElapsedSec(a, b) < 5.0
    println time.SinceNanos(a) >= 30000000, time.SinceMs(a) >= 30.0, time.SinceUs(a) >= 30000.0, time.SinceSec(a) < 5.0
    println time.SinceDuration(a).millis() >= 30
    println time.MonoMillis() > 0, time.MonoMicros() > 0
    println time.Now() >= start, time.Since(start) >= 0, time.Until(start + 60) <= 60
    println time.NowMillis() / 1000 >= start, time.NowMicros() / 1000000 >= start, time.NowNanos() / 1000000000 >= start
end
Outputtrue true true true true true true true true true true true true true true true

NowDateTime

func NowDateTime(): DateTime
The current instant as a DateTime.

The example for this item is shown with the ones above: time-Local.salam

FromEpoch

func FromEpoch(seconds: i64): DateTime
A DateTime from a number of epoch seconds.

The example for this item is shown with the ones above: time-Local.salam

Epoch

func Epoch(dt: DateTime): i64
The epoch seconds of a DateTime.

The example for this item is shown with the ones above: time-Local.salam

Year

func Year(epoch: i64): int
The year of this instant in the machine's local time.

The example for this item is shown with the ones above: time-Local.salam

Month

func Month(epoch: i64): int
The month, 1 to 12, of this instant in local time.

The example for this item is shown with the ones above: time-Local.salam

Day

func Day(epoch: i64): int
The day of the month of this instant in local time.

The example for this item is shown with the ones above: time-Local.salam

Hour

func Hour(epoch: i64): int
The hour, 0 to 23, of this instant in local time.

The example for this item is shown with the ones above: time-Local.salam

Minute

func Minute(epoch: i64): int
The minute of this instant in local time.

The example for this item is shown with the ones above: time-Local.salam

Second

func Second(epoch: i64): int
The second of this instant in local time.

The example for this item is shown with the ones above: time-Local.salam

YearUTC

func YearUTC(epoch: i64): int
The year of this instant in UTC.

The example for this item is shown with the ones above: time-UTC.salam

MonthUTC

func MonthUTC(epoch: i64): int
The month, 1 to 12, of this instant in UTC.

The example for this item is shown with the ones above: time-UTC.salam

DayUTC

func DayUTC(epoch: i64): int
The day of the month of this instant in UTC.

The example for this item is shown with the ones above: time-UTC.salam

HourUTC

func HourUTC(epoch: i64): int
The hour, 0 to 23, of this instant in UTC.

The example for this item is shown with the ones above: time-UTC.salam

MinuteUTC

func MinuteUTC(epoch: i64): int
The minute of this instant in UTC.

The example for this item is shown with the ones above: time-UTC.salam

SecondUTC

func SecondUTC(epoch: i64): int
The second of this instant in UTC.

The example for this item is shown with the ones above: time-UTC.salam

Weekday

func Weekday(epoch: i64): int
The day of the week in local time: zero is Sunday, one Monday, up to six for Saturday.

The example for this item is shown with the ones above: time-Local.salam

YearDay

func YearDay(epoch: i64): int
Which day of the year it is, counting from one, in local time.

The example for this item is shown with the ones above: time-Local.salam

FormatDate

func FormatDate(epoch: i64): str
The local date as 2024-03-20.

The example for this item is shown with the ones above: time-Local.salam

FormatTime

func FormatTime(epoch: i64): str
The local clock time as 09:30:00.

The example for this item is shown with the ones above: time-Local.salam

Format

func Format(epoch: i64): str
The local date and time with a space between them.

The example for this item is shown with the ones above: time-Local.salam

FormatISO

func FormatISO(epoch: i64): str
The local date and time in ISO 8601 without an offset, such as 2024-03-20T09:30:00.

The example for this item is shown with the ones above: time-Local.salam

FormatHTTPDate

func FormatHTTPDate(epoch: i64): str
The date format of HTTP headers, always in UTC: Wed, 20 Mar 2024 14:05:09 GMT.

The example for this item is shown with the ones above: time-UTC.salam

Sleep

func Sleep(ms: int)
Holds the program for a number of milliseconds.

The example for this item is shown with the ones above: time-Now.salam

DiffSeconds

func DiffSeconds(later: i64, earlier: i64): i64
How many seconds there are from earlier to later.

The example for this item is shown with the ones above: time-UTC.salam

Since

func Since(t: i64): i64
How many seconds have passed since that instant.

The example for this item is shown with the ones above: time-Now.salam

Until

func Until(t: i64): i64
How many seconds are left until that instant, negative when it is past.

The example for this item is shown with the ones above: time-Now.salam

Nanoseconds

func Nanoseconds(n: i64): Duration
A span of n nanoseconds.

The example for this item is shown with the ones above: time-Duration.salam

Microseconds

func Microseconds(n: i64): Duration
A span of n microseconds.

The example for this item is shown with the ones above: time-Duration.salam

Milliseconds

func Milliseconds(n: i64): Duration
A span of n milliseconds.

The example for this item is shown with the ones above: time-Duration.salam

Seconds

func Seconds(n: i64): Duration
A span of n seconds.

The example for this item is shown with the ones above: time-Duration.salam

Minutes

func Minutes(n: i64): Duration
A span of n minutes.

The example for this item is shown with the ones above: time-Duration.salam

Hours

func Hours(n: i64): Duration
A span of n hours.

The example for this item is shown with the ones above: time-Duration.salam

Days

func Days(n: i64): Duration
A span of n days.

The example for this item is shown with the ones above: time-Duration.salam

SecondsF

func SecondsF(x: f64): Duration
A span of a fractional number of seconds, such as 0.25 for a quarter second.

The example for this item is shown with the ones above: time-Duration.salam

ZeroDuration

func ZeroDuration(): Duration
A span of zero.

The example for this item is shown with the ones above: time-Duration.salam

FormatDuration

func FormatDuration(d: Duration): str
Writes the span short and readable: 42ns, 250us, 1.5s, 1m30s or 1h15m30.5s.

The example for this item is shown with the ones above: time-Duration.salam

ParseDuration

func ParseDuration(s: str): DurationResult
Reads text such as 1h15m30.5s or -250ms. The units are ns, us, ms, s, m, h and d for days.

The example for this item is shown with the ones above: time-Duration.salam

ParseDurationOr

func ParseDurationOr(s: str, fallback: Duration): Duration
Like ParseDuration, returning the default when the text is not valid.

The example for this item is shown with the ones above: time-Duration.salam

SleepFor

func SleepFor(d: Duration)
Sleeps for the given span.

The example for this item is shown with the ones above: time-Now.salam

SinceDuration

func SinceDuration(start_ns: i64): Duration
The span since an instant taken from MonoNanos.

The example for this item is shown with the ones above: time-Now.salam

DurationBetween

func DurationBetween(later: i64, earlier: i64): Duration
The span between two epoch instants.

The example for this item is shown with the ones above: time-UTC.salam

AddDuration

func AddDuration(epoch: i64, d: Duration): i64
Adds a span to an instant; any fraction of a second is dropped.

The example for this item is shown with the ones above: time-UTC.salam

NowNanos

func NowNanos(): i64
The current instant in nanoseconds since the Unix epoch.

The example for this item is shown with the ones above: time-Now.salam

NowMicros

func NowMicros(): i64
The current instant in microseconds since the Unix epoch.

The example for this item is shown with the ones above: time-Now.salam

NowMillis

func NowMillis(): i64
The current instant in milliseconds since the Unix epoch.

The example for this item is shown with the ones above: time-Now.salam

ElapsedMs

func ElapsedMs(start_ns: i64, end_ns: i64): f64
The gap between two nanosecond clock readings, in milliseconds.

The example for this item is shown with the ones above: time-Now.salam

ElapsedUs

func ElapsedUs(start_ns: i64, end_ns: i64): f64
The gap between two nanosecond clock readings, in microseconds.

The example for this item is shown with the ones above: time-Now.salam

ElapsedSec

func ElapsedSec(start_ns: i64, end_ns: i64): f64
The gap between two nanosecond clock readings, in seconds.

The example for this item is shown with the ones above: time-Now.salam

MonoNanos

func MonoNanos(): i64
The monotonic clock in nanoseconds. It never goes backwards, even if the system clock is changed, so use it for measuring spans. Its value on its own means nothing as a date.

The example for this item is shown with the ones above: time-Now.salam

MonoMicros

func MonoMicros(): i64
The monotonic clock in microseconds.

The example for this item is shown with the ones above: time-Now.salam

MonoMillis

func MonoMillis(): i64
The monotonic clock in milliseconds.

The example for this item is shown with the ones above: time-Now.salam

SinceNanos

func SinceNanos(start_ns: i64): i64
The nanoseconds that have passed since a monotonic clock reading.

The example for this item is shown with the ones above: time-Now.salam

SinceMs

func SinceMs(start_ns: i64): f64
The milliseconds, with a fraction, since a monotonic clock reading.

The example for this item is shown with the ones above: time-Now.salam

SinceUs

func SinceUs(start_ns: i64): f64
The microseconds, with a fraction, since a monotonic clock reading.

The example for this item is shown with the ones above: time-Now.salam

SinceSec

func SinceSec(start_ns: i64): f64
The seconds, with a fraction, since a monotonic clock reading.

The example for this item is shown with the ones above: time-Now.salam

ParseISO

func ParseISO(s: str): TimeResult
Reads an ISO 8601 date and time, such as 2024-03-20T17:35:09+03:30. Without an offset it assumes local time.

The example for this item is shown with the ones above: time-UTC.salam

ParseISOIn

func ParseISOIn(s: str, offsetMinutes: int): TimeResult
Like ParseISO, but without an offset it assumes offsetMinutes minutes.

The example for this item is shown with the ones above: time-UTC.salam

ParseHTTPDate

func ParseHTTPDate(s: str): TimeResult
Reads the date format of HTTP headers.

The example for this item is shown with the ones above: time-UTC.salam

ParseFormat

func ParseFormat(pattern: str, s: str): TimeResult
Reads text with a pattern. %Y is a four digit year, %y a two digit one, %m the month, %d the day, %H the hour, %M the minute, %S the second, %f the fraction, %b the English month name, %a the day name, which is ignored, %z an offset such as +0330 and %Z a zone name such as UTC. One space in the pattern matches any number of spaces in the text.

The example for this item is shown with the ones above: time-UTC.salam

ParseISOOr

func ParseISOOr(s: str, fallback: i64): i64
Like ParseISO, returning the default when the text is not valid.

The example for this item is shown with the ones above: time-UTC.salam

FormatISOUTC

func FormatISOUTC(epoch: i64): str
Writes the instant in UTC in ISO 8601, such as 2024-03-20T14:05:09Z.

The example for this item is shown with the ones above: time-UTC.salam

FormatRFC3339

func FormatRFC3339(epoch: i64): str
Writes the instant in local time with its offset, such as 2024-03-20T17:35:09+03:30, or Z when the offset is zero.

The example for this item is shown with the ones above: time-Local.salam

LocalOffsetMinutesAt

func LocalOffsetMinutesAt(epoch: i64): int
The difference between local time and UTC at that instant, in minutes. With daylight saving it can change over the year.

The example for this item is shown with the ones above: time-Local.salam

FromLocalParts

func FromLocalParts(year: int, month: int, day: int, hour: int, minute: int, second: int): i64
Builds an instant from a local year, month, day, hour, minute and second.

The example for this item is shown with the ones above: time-Local.salam

FromUTCParts

func FromUTCParts(year: int, month: int, day: int, hour: int, minute: int, second: int): i64
Builds an instant from UTC parts.

The example for this item is shown with the ones above: time-UTC.salam

NewTimer

func NewTimer(d: Duration): Timer
A timer that expires after the given span.

The example for this item is shown with the ones above: time-Timer.salam

NewTicker

func NewTicker(d: Duration): Ticker
A ticker with the given interval; a zero or negative interval makes an inactive ticker.

The example for this item is shown with the ones above: time-Timer.salam

AfterFunc

func AfterFunc(d: Duration, fn: func())
Waits for the given span and then runs the function. It happens on the same thread and does not return until the function is done.

The example for this item is shown with the ones above: time-Timer.salam

Every

func Every(d: Duration, fn: func(): bool): i64
Runs the function at a fixed interval for as long as it returns true, and returns how many times it ran.

The example for this item is shown with the ones above: time-Timer.salam

RepeatEvery

func RepeatEvery(d: Duration, count: int, fn: func())
Runs the function count times at the given interval.

The example for this item is shown with the ones above: time-Timer.salam

WaitUntil

func WaitUntil(fn: func(): bool, poll: Duration, limit: Duration): bool
Checks the condition once every poll until it holds or limit passes, and says whether it held.

The example for this item is shown with the ones above: time-Timer.salam