Documentation
¶
Overview ¶
Package times provides time formatting and timezone utilities.
It includes functions for formatting timestamps and calculating UTC offsets for local time zones.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var UTCOffset int64 = 28800000000
Functions ¶
func FixedTs ¶
FixedTs is a convenience function that adjusts the provided time.Time to a fixed timestamp by subtracting the predefined UTC offset (UTCOffset). Similar to FixedTsByLocation, this function addresses the issue of GORM returning time.Time values in UTC, which may not be correctly converted to local time zone strings by some database drivers. This version uses a predefined UTC offset, assuming the caller knows the required offset.
func FixedTsByLocation ¶
FixedTsByLocation adjusts the provided time.Time to a fixed timestamp by subtracting the microseconds offset of the given location from the Unix microsecond timestamp. This function is necessary because GORM returns all time.Time values in UTC, and this adjustment allows for converting them to the correct local time zone string, especially for database drivers that do not handle timezone conversions automatically.
func FormatTimestamp ¶
FormatTimestamp 将Unix时间戳格式化为指定的UTC时间字符串, 单位: ms
func FormatTsByLayout ¶
Types ¶
This section is empty.