Documentation
¶
Overview ¶
Package temporal implements the Cypher temporal types: DATE, LOCAL TIME, ZONED TIME, LOCAL DATETIME, ZONED DATETIME and DURATION. It covers construction (from strings, maps and other temporal values), component access, truncation, arithmetic, comparison, duration.between and the canonical string rendering that Cypher uses for output and storage.
The package depends only on the standard library.
Index ¶
- func Compare(a, b Value) (cmp int, ok bool)
- func Equal(a, b Value) bool
- func Property(v Value, name string) (any, bool)
- type Date
- type DateTime
- type Duration
- func (d Duration) Div(f float64) (Duration, error)
- func (Duration) Kind() Kind
- func (d Duration) Minus(o Duration) (Duration, error)
- func (d Duration) Neg() Duration
- func (d Duration) Plus(o Duration) (Duration, error)
- func (d Duration) Scale(f float64) (Duration, error)
- func (d Duration) String() string
- type Kind
- type LocalDateTime
- type LocalTime
- type Time
- type Value
- func Add(a, b Value) (Value, error)
- func Construct(kind Kind, arg any) (Value, error)
- func Now(kind Kind, m map[string]any, at time.Time) (Value, error)
- func Parse(kind Kind, s string) (Value, error)
- func Sub(a, b Value) (Value, error)
- func Truncate(kind Kind, unit string, v Value, m map[string]any) (Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare orders two values of the same orderable kind. ok is false for durations and for values of different kinds.
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
} // midnight UTC
Date is a calendar date.
func (Date) DayOfQuarter ¶
DayOfQuarter is the 1-based day within the quarter.
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
DateTime is a date and time with a UTC offset and optionally a region zone.
func FromEpochMillis ¶
FromEpochMillis builds a UTC datetime from milliseconds since the Unix epoch.
type Duration ¶
type Duration struct {
Months int64
Days int64
Seconds int64
Nanos int64 // 0 <= Nanos < 1e9; the sign of the whole is carried by Seconds
}
Duration is an amount of time in months, days and seconds, kept separately because months and days have no fixed length.
func Between ¶
Between computes duration.between (op "between"), duration.inMonths, duration.inDays or duration.inSeconds of two temporal values.
type Kind ¶
type Kind int
Kind identifies a temporal type.
func KindByName ¶
KindByName returns the kind a constructor function name refers to.
type LocalDateTime ¶
type LocalDateTime struct {
// contains filtered or unexported fields
} // wall clock, labelled UTC
LocalDateTime is a date and time without a zone.
func (LocalDateTime) Kind ¶
func (LocalDateTime) Kind() Kind
func (LocalDateTime) String ¶
func (t LocalDateTime) String() string
type LocalTime ¶
type LocalTime struct {
// contains filtered or unexported fields
} // nanoseconds since midnight
LocalTime is a time of day without a zone.
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time is a time of day with a UTC offset.
type Value ¶
Value is a temporal value. Its String method is the canonical Cypher rendering, which Parse accepts back.
func Add ¶
Add returns a + b for the supported combinations: temporal + duration, duration + temporal, and duration + duration.
func Construct ¶
Construct builds a value of the given kind from a string, a map or another temporal value. A nil argument is the caller's responsibility (null in, null out).
func Now ¶
Now returns the value of the given kind at the instant at, in the zone named by m's "timezone" entry (UTC when absent).