time

package
v0.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package time contains low-level utility functions for working with time.Time values and timezones.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertTimeToLocation added in v0.18.0

func ConvertTimeToLocation(datetime time.Time, location string) (time.Time, error)

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

func ConvertTimeZone(datetime time.Time, fromLocation string, toLocation string) (time.Time, bool)

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

func MySQLOffsetToDuration(d string) (time.Duration, error)

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

func SecondsToMySQLOffset(offset int) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL