timezone

package
v1.2.14 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Zero  = LocationLondon // 零时区
	Local = Zero           // 默认时区,零时区
)

Functions

func FixedTimestampUnixInZero added in v1.2.11

func FixedTimestampUnixInZero(timestamp int64, fixedLocation TimeZone) time.Time

FixedTimestampUnixInZero return time in Zero timezone with unix format timestamp from specified timezone

func FixedTimestampUnixMicroInZero added in v1.2.11

func FixedTimestampUnixMicroInZero(timestamp int64, fixedLocation TimeZone) int64

FixedTimestampUnixMicroInZero return time in Zero timezone with unix microsecond format timestamp from specified timezone

func FixedTimestampUnixMilliInZero added in v1.2.11

func FixedTimestampUnixMilliInZero(timestamp int64, fixedLocation TimeZone) int64

FixedTimestampUnixMilliInZero return time in Zero timezone with unix millisecond format timestamp from specified timezone

func FixedTimestampUnixNanoInZero added in v1.2.11

func FixedTimestampUnixNanoInZero(timestamp int64, fixedLocation TimeZone) int64

FixedTimestampUnixNanoInZero return time in Zero timezone with unix nanosecond format timestamp from specified timezone

func GetFixedTimeZone added in v1.2.11

func GetFixedTimeZone(zone TimeZone) *time.Location

GetFixedTimeZone returns fixed timezone, if timezone not exist, use Zero timezone

func NowInLocalTime added in v1.2.11

func NowInLocalTime() time.Time

NowInLocalTime return current time in Local timezone, if Local not set, use Zero timezone

func NowInLocalTimeUnix added in v1.2.11

func NowInLocalTimeUnix() int64

NowInLocalTimeUnix return current timestamp with unix format in Local timezone, if Local not set, use Zero timezone

func NowInLocalTimeUnixMicro added in v1.2.11

func NowInLocalTimeUnixMicro() int64

NowInLocalTimeUnixMicro return current timestamp with unix microsecond format in Local timezone, if Local not set, use Zero timezone

func NowInLocalTimeUnixMilli added in v1.2.11

func NowInLocalTimeUnixMilli() int64

NowInLocalTimeUnixMilli return current timestamp with unix millisecond format in Local timezone, if Local not set, use Zero timezone

func NowInLocalTimeUnixNano added in v1.2.11

func NowInLocalTimeUnixNano() int64

NowInLocalTimeUnixNano return current timestamp with unix nanosecond format in Local timezone, if Local not set, use Zero timezone

func NowInTimezone added in v1.2.11

func NowInTimezone(location TimeZone) time.Time

NowInTimezone return current time in specified timezone, if timezone not exist, use Zero timezone

func NowInTimezoneUnix added in v1.2.11

func NowInTimezoneUnix(location TimeZone) int64

NowInTimezoneUnix return current timestamp with unix format in specified timezone, if timezone not exist, use Zero timezone

func NowInTimezoneUnixMicro added in v1.2.11

func NowInTimezoneUnixMicro(location TimeZone) int64

NowInTimezoneUnixMicro return current timestamp with unix microsecond format in specified timezone, if timezone not exist, use Zero timezone

func NowInTimezoneUnixMilli added in v1.2.11

func NowInTimezoneUnixMilli(location TimeZone) int64

NowInTimezoneUnixMilli return current timestamp with unix millisecond format in specified timezone, if timezone not exist, use Zero timezone

func NowInTimezoneUnixNano added in v1.2.11

func NowInTimezoneUnixNano(location TimeZone) int64

NowInTimezoneUnixNano return current timestamp with unix nanosecond format in specified timezone, if timezone not exist, use Zero timezone

func NowInZeroTime added in v1.2.11

func NowInZeroTime() time.Time

NowInZeroTime return current time in Zero timezone

func NowInZeroTimeUnix added in v1.2.11

func NowInZeroTimeUnix() int64

NowInZeroTimeUnix return current timestamp with unix format in Zero timezone

func NowInZeroTimeUnixMicro added in v1.2.11

func NowInZeroTimeUnixMicro() int64

NowInZeroTimeUnixMicro return current timestamp with unix microsecond format in Zero timezone

func NowInZeroTimeUnixMilli added in v1.2.11

func NowInZeroTimeUnixMilli() int64

NowInZeroTimeUnixMilli return current timestamp with unix millisecond format in Zero timezone

func NowInZeroTimeUnixNano added in v1.2.11

func NowInZeroTimeUnixNano() int64

NowInZeroTimeUnixNano return current timestamp with unix nanosecond format in Zero timezone

func SetLocal

func SetLocal(timezone TimeZone) (err error)

SetLocal set timezone as Local timezone example:

err := timezone.SetLocal(timezone.LocationBeijing)

func UnixMicroTimestampInLocal added in v1.2.11

func UnixMicroTimestampInLocal(timestamp int64) time.Time

UnixMicroTimestampInLocal return time in Local timezone with unix microsecond format

func UnixMicroTimestampInTimezone added in v1.2.11

func UnixMicroTimestampInTimezone(timestamp int64, location TimeZone) time.Time

UnixMicroTimestampInTimezone return time in specified timezone with unix microsecond format, if timezone not exist, use Zero timezone

func UnixMicroTimestampInZero added in v1.2.11

func UnixMicroTimestampInZero(timestamp int64) time.Time

UnixMicroTimestampInZero return time in Zero timezone with unix microsecond format

func UnixMilliTimestampInLocal added in v1.2.11

func UnixMilliTimestampInLocal(timestamp int64) time.Time

UnixMilliTimestampInLocal return time in Local timezone with unix millisecond format

func UnixMilliTimestampInTimezone added in v1.2.11

func UnixMilliTimestampInTimezone(timestamp int64, location TimeZone) time.Time

UnixMilliTimestampInTimezone return time in specified timezone with unix millisecond format, if timezone not exist, use Zero timezone

func UnixMilliTimestampInZero added in v1.2.11

func UnixMilliTimestampInZero(timestamp int64) time.Time

UnixMilliTimestampInZero return time in Zero timezone with unix millisecond format

func UnixNanoTimestampInLocal added in v1.2.11

func UnixNanoTimestampInLocal(timestamp int64) time.Time

UnixNanoTimestampInLocal return time in Local timezone with unix nanosecond format

func UnixNanoTimestampInTimezone added in v1.2.11

func UnixNanoTimestampInTimezone(timestamp int64, location TimeZone) time.Time

UnixNanoTimestampInTimezone return time in specified timezone with unix nanosecond format, if timezone not exist, use Zero timezone

func UnixNanoTimestampInZero added in v1.2.11

func UnixNanoTimestampInZero(timestamp int64) time.Time

UnixNanoTimestampInZero return time in Zero timezone with unix nanosecond format

func UnixTimestampInLocal added in v1.2.11

func UnixTimestampInLocal(timestamp int64) time.Time

UnixTimestampInLocal return time in Local timezone with unix format

func UnixTimestampInTimezone added in v1.2.11

func UnixTimestampInTimezone(timestamp int64, location TimeZone) time.Time

UnixTimestampInTimezone return time in specified timezone with unix format, if timezone not exist, use Zero timezone

func UnixTimestampInZero added in v1.2.11

func UnixTimestampInZero(timestamp int64) time.Time

UnixTimestampInZero return time in Zero timezone with unix format

Types

type TimeZone

type TimeZone string
const (
	LocationBeijing      TimeZone = "Asia/Beijing"
	LocationShanghai     TimeZone = "Asia/Shanghai"
	LocationTokyo        TimeZone = "Asia/Tokyo"
	LocationLondon       TimeZone = "Europe/London"
	LocationParis        TimeZone = "Europe/Paris"
	LocationNewYork      TimeZone = "America/New_York"
	LocationLosAnge      TimeZone = "America/Los_Angeles"
	LocationMoscow       TimeZone = "Europe/Moscow"
	LocationMonaco       TimeZone = "Europe/Monaco"
	LocationKarachi      TimeZone = "Asia/Karachi"
	LocationSydney       TimeZone = "Australia/Sydney"
	LocationSeoul        TimeZone = "Asia/Seoul"
	LocationNewDelhi     TimeZone = "Asia/New_Delhi"
	LocationJohannesburg TimeZone = "Africa/Johannesburg"
	LocationMadrid       TimeZone = "Europe/Madrid"
	LocationDubai        TimeZone = "Asia/Dubai"
	LocationBerlin       TimeZone = "Europe/Berlin"
	LocationRome         TimeZone = "Europe/Rome"
	LocationHonolulu     TimeZone = "Pacific/Honolulu"
	LocationPrague       TimeZone = "Europe/Prague"
	LocationBucharest    TimeZone = "Europe/Bucharest"
	LocationWarsaw       TimeZone = "Europe/Warsaw"
	LocationAthens       TimeZone = "Europe/Athens"
	LocationHelsinki     TimeZone = "Europe/Helsinki"
	LocationStockholm    TimeZone = "Europe/Stockholm"
	LocationCopenhagen   TimeZone = "Europe/Copenhagen"
	LocationOslo         TimeZone = "Europe/Oslo"
	LocationVienna       TimeZone = "Europe/Vienna"
	LocationBrussels     TimeZone = "Europe/Brussels"
	LocationAmsterdam    TimeZone = "Europe/Amsterdam"
	LocationDublin       TimeZone = "Europe/Dublin"
	LocationLisbon       TimeZone = "Europe/Lisbon"
	LocationBern         TimeZone = "Europe/Bern"
	LocationZurich       TimeZone = "Europe/Zurich"
	LocationKeiv         TimeZone = "Europe/Keiv"

	LocationUTC           TimeZone = "UTC"
	LocationUTCEast1      TimeZone = "UTC+1"
	LocationUTCEast2      TimeZone = "UTC+2"
	LocationUTCEast3      TimeZone = "UTC+3"
	LocationUTCEast3Dot5  TimeZone = "UTC+3.5"
	LocationUTCEast4      TimeZone = "UTC+4"
	LocationUTCEast4Dot5  TimeZone = "UTC+4.5"
	LocationUTCEast5      TimeZone = "UTC+5"
	LocationUTCEast5Dot5  TimeZone = "UTC+5.5"
	LocationUTCEast5Dot75 TimeZone = "UTC+5.75"
	LocationUTCEast6      TimeZone = "UTC+6"
	LocationUTCEast7      TimeZone = "UTC+7"
	LocationUTCEast8      TimeZone = "UTC+8"
	LocationUTCEast9      TimeZone = "UTC+9"
	LocationUTCEast9Dot5  TimeZone = "UTC+9.5"
	LocationUTCEast10     TimeZone = "UTC+10"
	LocationUTCEast10Dot5 TimeZone = "UTC+10.5"
	LocationUTCEast11     TimeZone = "UTC+11"
	LocationUTCEast12     TimeZone = "UTC+12"
	LocationUTCEast13     TimeZone = "UTC+13"
	LocationUTCEast14     TimeZone = "UTC+14"
	LocationUTCWest1      TimeZone = "UTC-1"
	LocationUTCWest2      TimeZone = "UTC-2"
	LocationUTCWest3      TimeZone = "UTC-3"
	LocationUTCWest4      TimeZone = "UTC-4"
	LocationUTCWest5      TimeZone = "UTC-5"
	LocationUTCWest6      TimeZone = "UTC-6"
	LocationUTCWest7      TimeZone = "UTC-7"
	LocationUTCWest8      TimeZone = "UTC-8"
	LocationUTCWest9      TimeZone = "UTC-9"
	LocationUTCWest10     TimeZone = "UTC-10"
	LocationUTCWest11     TimeZone = "UTC-11"
	LocationUTCWest12     TimeZone = "UTC-12"
)

Jump to

Keyboard shortcuts

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