Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider provides timezones.
func CreateProvider ¶
CreateProvider creates a timezone Provider from given zones and version. Each zone ID in the given zones must be unique. For each zone of the zones, the transitions of the zone must be sorted in ascending order with respect to TransitionTimestamp field. OffsetMinutesAfter field of each transition of the transitions must match OffsetMinutesBefore field of the successor transition.
func LoadProvider ¶
LoadProvider parses a JSON and returns a timezone Provider. tzotJSONBytes must be a JSON that is according to the format of tz-offset-transitions. https://github.com/Jumpaku/tz-offset-transitions
func (Provider) AvailableZoneIDs ¶
AvailableZoneIDs returns the timezone IDs of the available timezones.
type Rule ¶
type Rule interface { // Transition returns the transition of the timezone offset in the given year. Transition(year int) Transition // contains filtered or unexported methods }
Rule defines when the yearly timezone offset transition occurs in the future.
type Transition ¶
type Transition struct { TransitionTimestamp tokiope.Instant OffsetMinutesBefore datetime.OffsetMinutes OffsetMinutesAfter datetime.OffsetMinutes }
Transition represents a timezone offset transition.
type Zone ¶
type Zone struct {
// contains filtered or unexported fields
}
Zone represents a timezone with transitions and rules.
func Create ¶
func Create(zoneID string, transitions []Transition, rules []Rule) Zone
Create creates a Zone with the given zone ID and transitions. The transitions must be sorted in ascending order with respect to TransitionTimestamp field. OffsetMinutesAfter field of each transition of the transitions must match OffsetMinutesBefore field of the successor transition.
func CreateFixed ¶
func CreateFixed(zoneID string, offset datetime.OffsetMinutes) Zone
CreateFixed creates a Zone with the given zone ID and fixed offset.
func (Zone) FindOffset ¶
func (z Zone) FindOffset(at tokiope.Instant) datetime.OffsetMinutes
FindOffset finds the timezone offset at the given instant.
type ZonedDateTime ¶
type ZonedDateTime interface { // Date returns the date of the zoned datetime. Date() calendar.Date // Time returns the time of the zoned datetime. Time() datetime.Time // Zone returns the timezone of the zoned datetime. Zone() Zone // String returns the string representation of the zoned datetime. String() string // InstantCandidates returns the possible instants corresponding to the zoned datetime. // The returned slice contains a single instant if the corresponding instant exists uniquely. // The returned slice is empty if the corresponding instant does not exist due to gaps. // The returned slice contains multiple instants in ascending order if the corresponding instants are possible due to overlaps. InstantCandidates() []tokiope.Instant }
ZonedDateTime represents a datetime with a timezone. Note that ZonedDateTime may represent no Instant or multiple possible Instants.
func NewZonedDateTime ¶
NewZonedDateTime creates a ZonedDateTime from the date, time, and zone.