cockroach: Index | Files

package timetz

import ""


Package Files



var (
    // MaxTimeTZOffsetSecs is the maximum offset TimeTZ allows in seconds.
    // NOTE: postgres documentation mentions 14:59, but up to 15:59 is accepted.
    MaxTimeTZOffsetSecs = int32((15*time.Hour + 59*time.Minute) / time.Second)
    // MinTimeTZOffsetSecs is the minimum offset TimeTZ allows in seconds.
    // NOTE: postgres documentation mentions -14:59, but up to -15:59 is accepted.
    MinTimeTZOffsetSecs = -1 * MaxTimeTZOffsetSecs

type TimeTZ Uses

type TimeTZ struct {
    // TimeOfDay is the time since midnight in a given zone
    // dictated by OffsetSecs.
    // OffsetSecs is the offset of the zone, with the sign reversed.
    // e.g. -0800 (PDT) would have OffsetSecs of +8*60*60.
    // This is in line with the postgres implementation.
    // This means timeofday.Secs() + OffsetSecs = UTC secs.
    OffsetSecs int32

TimeTZ is an implementation of postgres' TimeTZ. Note that in this implementation, if time is equal in terms of UTC time the zone offset is further used to differentiate.

func MakeTimeTZ Uses

func MakeTimeTZ(t timeofday.TimeOfDay, offsetSecs int32) TimeTZ

MakeTimeTZ creates a TimeTZ from a TimeOfDay and offset.

func MakeTimeTZFromLocation Uses

func MakeTimeTZFromLocation(t timeofday.TimeOfDay, loc *time.Location) TimeTZ

MakeTimeTZFromLocation creates a TimeTZ from a TimeOfDay and time.Location.

func MakeTimeTZFromTime Uses

func MakeTimeTZFromTime(t time.Time) TimeTZ

MakeTimeTZFromTime creates a TimeTZ from a time.Time. It will be trimmed to microsecond precision.

func Now Uses

func Now() TimeTZ

Now returns the TimeTZ of the current location.

func ParseTimeTZ Uses

func ParseTimeTZ(now time.Time, s string, precision time.Duration) (TimeTZ, error)

ParseTimeTZ parses and returns the TimeTZ represented by the provided string, or an error if parsing is unsuccessful.

func (*TimeTZ) After Uses

func (t *TimeTZ) After(other TimeTZ) bool

After returns whether the TimeTZ is after the other TimeTZ.

func (*TimeTZ) Before Uses

func (t *TimeTZ) Before(other TimeTZ) bool

Before returns whether the current is before the other TimeTZ.

func (*TimeTZ) Equal Uses

func (t *TimeTZ) Equal(other TimeTZ) bool

Equal returns whether the TimeTZ is equal to the other TimeTZ.

func (*TimeTZ) Round Uses

func (t *TimeTZ) Round(precision time.Duration) TimeTZ

Round rounds a DTimeTZ to the given duration.

func (*TimeTZ) String Uses

func (t *TimeTZ) String() string

String implements the Stringer interface.

func (*TimeTZ) ToDuration Uses

func (t *TimeTZ) ToDuration() time.Duration

ToDuration returns the TimeTZ as an offset duration from UTC midnight.

func (*TimeTZ) ToTime Uses

func (t *TimeTZ) ToTime() time.Time

ToTime converts a DTimeTZ to a time.Time, corrected to the given location.

Package timetz imports 8 packages (graph) and is imported by 8 packages. Updated 2019-12-31. Refresh now. Tools for package owners.