~/bend-docscommunity

clock.bend relies on unsafe/foreign

raw source on the hub · import cswap-bend-cli@0.1.0.0/clock.bend as Clock

1 import
import Base

Definitions

def now_s source · line 13 · raw

IO(U32)

def sel source · line 16 · raw

@c:Bool -> @x:U32 -> @y:U32 -> U32

def sel.s source · line 23 · raw

@c:Bool -> @x:String -> @y:String -> String

def pad2 source · line 32 · raw

@+n:U32 -> String

def pad4 source · line 35 · raw

@+n:U32 -> String

def civil.adj source · line 40 · raw

@+y:U32 -> @+m:U32 -> @d:U32 -> Pair(U32, Pair(U32, U32))

Civil date (year, (month, day)) of a day count since 1970-01-01 (Hinnant's civil_from_days, all unsigned: z + 719468 is positive).

def civil.ymd source · line 43 · raw

@+y:U32 -> @+mp:U32 -> @+doy:U32 -> Pair(U32, Pair(U32, U32))

def civil.fin source · line 46 · raw

@+yoe:U32 -> @+era:U32 -> @+doy:U32 -> Pair(U32, Pair(U32, U32))

def civil.doy source · line 49 · raw

@+era:U32 -> @+doe:U32 -> @+yoe:U32 -> Pair(U32, Pair(U32, U32))

def civil.yoe source · line 52 · raw

@+era:U32 -> @+doe:U32 -> Pair(U32, Pair(U32, U32))

def civil.doe source · line 55 · raw

@+z:U32 -> Pair(U32, Pair(U32, U32))

def civil source · line 58 · raw

@days:U32 -> Pair(U32, Pair(U32, U32))

def iso.fmt source · line 61 · raw

@ymd:Pair(U32, Pair(U32, U32)) -> @+s:U32 -> @suffix:String -> String

def iso8601_utc source · line 67 · raw

@+t:U32 -> String

2026-10-30T09:00:00Z, as the reference's strftime writes it.

def iso8601_offset source · line 71 · raw

@+t:U32 -> String

2026-10-30T09:00:00+00:00, as the reference's isoformat writes it.

def all_digits source · line 76 · raw

@s:String -> Bool

def num.pick source · line 83 · raw

@ok:Bool -> @s:String -> Maybe<&2, U32>

def num source · line 91 · raw

@+s:String -> @off:Nat -> @+n:Nat -> Maybe<&2, U32>

The n digits of s at offset off, as a number.

def at.pick source · line 95 · raw

@m:Maybe<&2, Char> -> @a:Char -> @b:Char -> Bool

def at source · line 103 · raw

@+s:String -> @i:Nat -> @a:Char -> @b:Char -> Bool

True when the char at i is a or b.

def valid source · line 106 · raw

@+y:U32 -> @+mo:U32 -> @+d:U32 -> @+h:U32 -> @+mi:U32 -> @+s:U32 -> Bool

def days.era source · line 110 · raw

@+era:U32 -> @+yoe:U32 -> @+doy:U32 -> U32

def days.fin source · line 113 · raw

@+y:U32 -> @+mp:U32 -> @+d:U32 -> U32

def days source · line 117 · raw

@+y:U32 -> @+m:U32 -> @+d:U32 -> U32

Days since 1970-01-01 of a civil date (days_from_civil; y >= 1970).

def digits_end.pick source · line 120 · raw

@d:Bool -> @c:Char -> @t:String -> @dropped:String -> String

def digits_end source · line 128 · raw

@s:String -> String

Drop a leading run of digits.

def frac.pick source · line 135 · raw

@dot:Bool -> @c:Char -> @t:String -> String

def frac source · line 142 · raw

@s:String -> String

def tz.min.sel source · line 149 · raw

@a:Bool -> @b:Bool -> @c:Bool -> @+t:String -> Maybe<&2, U32>

def tz.min.pick source · line 160 · raw

@+n:Nat -> @+t:String -> Maybe<&2, U32>

def tz.min source · line 163 · raw

@+t:String -> Maybe<&2, U32>

def tz.off.pick source · line 166 · raw

@ok:Bool -> @neg:Bool -> @+mag:U32 -> Maybe<&2, U32>

def tz.off source · line 176 · raw

@neg:Bool -> @+h:U32 -> @+m:U32 -> Maybe<&2, U32>

The zone offset in seconds, biased by 86400 so it stays unsigned: Z, +HH:MM, -HH, +HHMM, or none (read as UTC, as the reference's naive stamps are).

def tz.hm source · line 179 · raw

@neg:Bool -> @+t:String -> Maybe<&2, U32>

def tz.z source · line 185 · raw

@t:String -> Maybe<&2, U32>

def tz.head source · line 192 · raw

@z:Bool -> @plus:Bool -> @minus:Bool -> @t:String -> Maybe<&2, U32>

def tz source · line 203 · raw

@s:String -> Maybe<&2, U32>

def shift source · line 211 · raw

@+local:U32 -> @biased:U32 -> U32

local = utc + offset, so utc = local - offset (offset = biased - 86400).

def finish source · line 214 · raw

@ok:Bool -> @+local:U32 -> @off:Maybe<&2, U32> -> Maybe<&2, U32>

def parse.fin source · line 223 · raw

@+s:String -> @+y:U32 -> @+mo:U32 -> @+d:U32 -> @+h:U32 -> @+mi:U32 -> @+sec:U32 -> Maybe<&2, U32>

def parse.time source · line 228 · raw

@+s:String -> @y:U32 -> @mo:U32 -> @d:U32 -> Maybe<&2, U32>

def parse_iso8601 source · line 237 · raw

@+s:String -> Maybe<&2, U32>

Unix seconds of 2026-10-30T09:00:00+00:00, ...Z, ...00.123456Z, a -HH:MM offset, or a bare stamp (read as UTC); None when malformed.

Effects (foreign code)

effect Clock.now_s source · line 9 · raw

IO(U32)

Unix seconds now. The foreign effect calls time(2); Base's IO.now is a monotonic tick, not wall time.

foreign: effs/now_s.c, effs/now_s.js