time

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 7 Imported by: 0

README

time

time defines time primitives for starlark

Functions

duration(string) duration

parse a duration

location(string) location

parse a location

now() time

implementations would be able to make this a constant

time(string, format=..., location=...) time

parse a time

zero() time

a constant

Types

duration

Fields

name type description
hours float
minutes float
nanoseconds int
seconds float
time

Fields

name type description
year int
month int
day int
hour int
minute int
second int
nanosecond int

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

View Source
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

View Source
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

type Duration gotime.Duration

Duration is a starlark representation of a duration

func (Duration) Attr

func (d Duration) Attr(name string) (starlark.Value, error)

Attr gets a value for a string attribute, implementing dot expression support in starklark. required by starlark.HasAttrs interface

func (Duration) AttrNames

func (d Duration) AttrNames() []string

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

func (d Duration) Hash() (uint32, error)

Hash returns a function of x such that Equals(x, y) => Hash(x) == Hash(y) required by starlark.Value interface

func (Duration) String

func (d Duration) String() string

String implements the Stringer interface

func (Duration) Truth

func (d Duration) Truth() starlark.Bool

Truth returns the truth value of an object required by starlark.Value interface

func (Duration) Type

func (d Duration) Type() string

Type returns a short string describing the value's type.

type Time

type Time gotime.Time

Time is a starlark representation of a point in time

func (Time) Attr

func (t Time) Attr(name string) (starlark.Value, error)

Attr gets a value for a string attribute, implementing dot expression support in starklark. required by starlark.HasAttrs interface

func (Time) AttrNames

func (t Time) AttrNames() []string

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

func (t Time) CompareSameType(op syntax.Token, yV starlark.Value, depth int) (bool, error)

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

func (t Time) Hash() (uint32, error)

Hash returns a function of x such that Equals(x, y) => Hash(x) == Hash(y) required by starlark.Value interface

func (Time) String

func (t Time) String() string

String implements the Stringer interface

func (Time) Truth

func (t Time) Truth() starlark.Bool

Truth returns the truth value of an object required by starlark.Value interface

func (Time) Type

func (t Time) Type() string

Type returns a short string describing the value's type.

Jump to

Keyboard shortcuts

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