libtime

package
v1.75.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

Package libtime provides immutable wall-clock timestamps and duration operations. Owned timestamps preserve timezone/calendar rules without exposing shared mutable Go timezone objects; use Time and Get at Go boundaries.

Index

Constants

View Source
const DefaultPackageName = "time"

DefaultPackageName is the package name used by LoadPackage.

Variables

This section is empty.

Functions

func BuiltinDurationBetween

func BuiltinDurationBetween(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinDurationMS

func BuiltinDurationMS(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

BuiltinDuriationNS returns a float equal to the the number of nanoseconds in the given duration.

func BuiltinDurationNS

func BuiltinDurationNS(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

BulitinDuriationNS returns an integer equal to the the number of nanoseconds in the given duration.

func BuiltinDurationSeconds

func BuiltinDurationSeconds(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

BulitinDurationSecods returns a float equal to the the number of seconds in the given duration.

func BuiltinFormatRFC3339

func BuiltinFormatRFC3339(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinFormatRFC3339Nano

func BuiltinFormatRFC3339Nano(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinParseDuration

func BuiltinParseDuration(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinParseRFC3339

func BuiltinParseRFC3339(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinParseRFC3339Nano

func BuiltinParseRFC3339Nano(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinSleep

func BuiltinSleep(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

BuiltinSleep sleeps for the given duration before returning.

LoadPackage does not register it: the time package offers no builtin whose result depends on goroutine timing (#757). It stays exported for hosts that register a sleep in their own package, with formals (time-duration &key max).

The sleep is bounded by the evaluation's context (see LEnv.Context): it wakes early if the context is cancelled, and never sleeps past the context's deadline. See sleepContext for the full rationale.

func BuiltinTimeAdd

func BuiltinTimeAdd(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinTimeEq

func BuiltinTimeEq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinTimeGT

func BuiltinTimeGT(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func BuiltinTimeLT

func BuiltinTimeLT(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func Duration

func Duration(d time.Duration) *lisp.LVal

Duration returns an LVal representing duration d.

func Get

func Get(v *lisp.LVal) (time.Time, bool)

Get returns a Go time.Time with an independent timezone object. Mutating its Location cannot change v or another export. The timezone's value is preserved, not its pointer identity. Nil and non-native values return the zero time and false. Raw host time.Time natives remain supported, but are not automatically approved for template sharing.

func GetDuration

func GetDuration(v *lisp.LVal) (time.Duration, bool)

GetDuration gets a time.Duration value from v and returns it.

func LoadPackage

func LoadPackage(env *lisp.LEnv) *lisp.LVal

LoadPackage adds the time package to env

func Time

func Time(t time.Time) *lisp.LVal

Time creates an immutable native wall-clock value representing t. It takes an independent snapshot of t's timezone object, preserving named-zone and daylight-saving rules but dropping Go monotonic clock metadata. The native payload is private; use Get to obtain an independent Go time.Time value. Callers must not mutate t's timezone concurrently with this call. This does not make capturing wall-clock time during template initialization equivalent to reading the clock independently during each cold load.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL