magus v0.3.0 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
1 min read

time

Timestamp formatting/parsing and duration parsing (Go time, UTC).

Naming convention: import the module under its bare name (import "time"), reach members with a backslash, and call methods in camelCase: time\someMethod.

Methods

format

Render Unix-millis as a string using a Go reference layout (UTC).

Signature: time\format(layout, unix_millis) → string · source

Parameter Type Optional Description
layout string
unix_millis float64

Returns: string

parse

Parse a string with a Go reference layout into Unix-millis (UTC); errors on mismatch.

Signature: time\parse(layout, value) → float64 · source

Parameter Type Optional Description
layout string
value string

Returns: float64

parseDuration

Parse a Go duration string (e.g. "168h", "1h30m") into milliseconds; errors on mismatch.

Signature: time\parseDuration(duration) → float64 · source

Parameter Type Optional Description
duration string

Returns: float64

nowIso

Return the current UTC time as an RFC 3339 string. For the raw epoch-millis value use Buzz's os.time().

Signature: time\nowIso() → string · source

Returns: string

add

Add a Go duration string (e.g. "24h", "-1h30m") to a Unix-millis timestamp; returns the new Unix-millis timestamp.

Signature: time\add(unix_millis, duration) → float64 · source

Parameter Type Optional Description
unix_millis float64
duration string

Returns: float64

diff

Return a minus b in milliseconds (positive when a is later than b).

Signature: time\diff(a, b) → float64 · source

Parameter Type Optional Description
a float64
b float64

Returns: float64

auto-generatedtimemodulestdlibmagusfile
Last updated (e0463131)
Earlier changes on this page (1)

Full history ↗ · Blame source ↗

Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.