Documentation ¶
Overview ¶
Package time defines time primitives for starlark, based heavily on the time package from the go standard library.
outline: time time defines time primitives for starlark functions: duration(string) duration parse a duration location(string) location parse a location time(string, format=..., location=...) time parse a time now() time implementations would be able to make this a constant zero() time a constant types: duration fields: hours float minutes float nanoseconds int seconds float operators: duration - time = duration duration + time = time duration == duration = boolean duration < duration = booleans time fields: year int month int day int hour int minute int second int nanosecond int operators: time == time = boolean time < time = boolean time + duration = time time - duration = time time - time = duration
Index ¶
- Constants
- Variables
- func LoadModule() (starlark.StringDict, error)
- type Duration
- func (d Duration) Attr(name string) (starlark.Value, error)
- func (d Duration) AttrNames() []string
- func (d Duration) Binary(op syntax.Token, yV starlark.Value, side starlark.Side) (starlark.Value, error)
- func (d Duration) Freeze()
- func (d Duration) Hash() (uint32, error)
- func (d Duration) String() string
- func (d Duration) Truth() starlark.Bool
- func (d Duration) Type() string
- type Time
- func (t Time) Attr(name string) (starlark.Value, error)
- func (t Time) AttrNames() []string
- func (t Time) Binary(op syntax.Token, yV starlark.Value, side starlark.Side) (starlark.Value, error)
- func (t Time) CompareSameType(op syntax.Token, yV starlark.Value, depth int) (bool, error)
- func (t Time) Freeze()
- func (t Time) Hash() (uint32, error)
- func (t Time) String() string
- func (t Time) Truth() starlark.Bool
- func (t Time) Type() string
Constants ¶
const ModuleName = "time.star"
ModuleName defines the expected name for this Module when used in starlark's load() function, eg: load('time.star', 'time')
Variables ¶
var NowFunc = func() gotime.Time { return gotime.Now() }
NowFunc is a function that generates the current time. Intentionally exported so that it can be overridden
Functions ¶
func LoadModule ¶
func LoadModule() (starlark.StringDict, error)
LoadModule loads the time module. It is concurrency-safe and idempotent.
Types ¶
type Duration ¶
Duration is a starlark representation of a duration
func (Duration) Attr ¶
Attr gets a value for a string attribute, implementing dot expression support in starklark. required by starlark.HasAttrs interface
func (Duration) AttrNames ¶
AttrNames lists available dot expression strings. required by starlark.HasAttrs interface
func (Duration) Binary ¶
func (d Duration) Binary(op syntax.Token, yV starlark.Value, side starlark.Side) (starlark.Value, error)
Binary implements binary operators, which satisfies the starlark.HasBinary interface
func (Duration) Freeze ¶
func (d Duration) Freeze()
Freeze renders Duration immutable. required by starlark.Value interface because duration is already immutable this is a no-op
func (Duration) Hash ¶
Hash returns a function of x such that Equals(x, y) => Hash(x) == Hash(y) required by starlark.Value interface
type Time ¶
Time is a starlark representation of a point in time
func (Time) Attr ¶
Attr gets a value for a string attribute, implementing dot expression support in starklark. required by starlark.HasAttrs interface
func (Time) AttrNames ¶
AttrNames lists available dot expression strings for time. required by starlark.HasAttrs interface
func (Time) Binary ¶
func (t Time) Binary(op syntax.Token, yV starlark.Value, side starlark.Side) (starlark.Value, error)
Binary implements binary operators, which satisfies the starlark.HasBinary interface
func (Time) CompareSameType ¶
CompareSameType implements comparison of two Time values. required by starlark.Comparable interface
func (Time) Freeze ¶
func (t Time) Freeze()
Freeze renders time immutable. required by starlark.Value interface because Time is already immutable this is a no-op
func (Time) Hash ¶
Hash returns a function of x such that Equals(x, y) => Hash(x) == Hash(y) required by starlark.Value interface