Documentation
¶
Overview ¶
Package time contains low-level utility functions for working with time.Time values and timezones.
Index ¶
- func ConvertTimeToLocation(datetime time.Time, location string) (time.Time, error)
- func ConvertTimeZone(datetime time.Time, fromLocation string, toLocation string) (time.Time, bool)
- func MySQLOffsetToDuration(d string) (time.Duration, error)
- func SecondsToMySQLOffset(offset int) string
- func SystemTimezoneName() string
- func SystemTimezoneOffset() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertTimeToLocation ¶ added in v0.18.0
ConvertTimeToLocation converts |datetime| to the given |location|. |location| can be either the name of a timezone (e.g. "UTC") or a MySQL-formatted timezone offset (e.g. "+01:00"). If the time was converted successfully, then the converted time is returned, otherwise an error is returned.
func ConvertTimeZone ¶
ConvertTimeZone converts |datetime| from one timezone to another. |fromLocation| and |toLocation| can be either the name of a timezone (e.g. "UTC") or a MySQL-formatted timezone offset (e.g. "+01:00"). If the time was converted successfully, then the second return value will be true, otherwise the time was not able to be converted.
func MySQLOffsetToDuration ¶
MySQLOffsetToDuration takes in a MySQL timezone offset (e.g. "+01:00") and returns it as a time.Duration. If any problems are encountered, an error is returned.
func SecondsToMySQLOffset ¶
SecondsToMySQLOffset takes in a timezone offset in seconds (as returned by time.Time.Zone()) and returns it as a MySQL timezone offset (e.g. "+01:00").
func SystemTimezoneName ¶ added in v0.18.0
func SystemTimezoneName() string
SystemTimezoneName returns the current system timezone name.
func SystemTimezoneOffset ¶
func SystemTimezoneOffset() string
SystemTimezoneOffset returns the current system timezone offset as a MySQL timezone offset (e.g. "+01:00").
Types ¶
This section is empty.