Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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 )
Functions ¶
This section is empty.
Types ¶
type TimeTZ ¶
type TimeTZ struct {
// TimeOfDay is the time since midnight in a given zone
// dictated by OffsetSecs.
timeofday.TimeOfDay
// 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 ¶
MakeTimeTZ creates a TimeTZ from a TimeOfDay and offset.
func MakeTimeTZFromLocation ¶
MakeTimeTZFromLocation creates a TimeTZ from a TimeOfDay and time.Location.
func MakeTimeTZFromTime ¶
MakeTimeTZFromTime creates a TimeTZ from a time.Time. It will be trimmed to microsecond precision.
func ParseTimeTZ ¶
ParseTimeTZ parses and returns the TimeTZ represented by the provided string, or an error if parsing is unsuccessful.
func (*TimeTZ) ToDuration ¶
ToDuration returns the TimeTZ as an offset duration from UTC midnight.
Click to show internal directories.
Click to hide internal directories.