dt

package
v1.8.80 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDurationFormat = fmt.Errorf("invalid duration format")
	ErrInvalidNumber         = fmt.Errorf("invalid number")
	ErrInvalidTimeUnit       = fmt.Errorf("invalid time unit")
)

Functions

func AdjustMilliTimestamp added in v1.8.19

func AdjustMilliTimestamp(timestamp uint64, seconds int64) uint64

AdjustMilliTimestamp 根据 13 位数字毫秒时间戳和加减秒数,返回计算后的时间戳

func AdjustMilliTimestampByStr added in v1.8.25

func AdjustMilliTimestampByStr(timestamp uint64, shift string) (uint64, error)

AdjustMilliTimestampByStr 根据传入的时间单位(如 "1d", "-1m","1y")对当前时间戳进行加减,并返回结果毫秒时间戳

func CompareTimeStrings added in v1.8.68

func CompareTimeStrings(t1, t2, layout string) (int, error)

CompareTimeStrings 比较两个时间字符串,返回 -1, 0, 1 分别表示第一个时间小于、等于、大于第二个时间

func ConvertStrMillisToTime added in v1.8.56

func ConvertStrMillisToTime(millis string) (time.Time, error)

ConvertStrMillisToTime 将字符串格式的毫秒时间戳转换为 time.Time

func GetMicroTimestampStr added in v1.8.68

func GetMicroTimestampStr() string

GetMicroTimestampStr 当前时间的微秒时间戳字符串

func GetMilliTimestampStr added in v1.8.68

func GetMilliTimestampStr() string

GetMilliTimestampStr 当前时间的毫秒时间戳字符串

func GetNanoTimestampStr added in v1.8.68

func GetNanoTimestampStr() string

GetNanoTimestampStr 当前时间的纳秒时间戳字符串

func GetTimezoneOffsetByMillis

func GetTimezoneOffsetByMillis(millis int64) (string, error)

GetTimezoneOffsetByMillis 计算客户端时区偏移量和时区名称

func SetTimezone added in v1.8.68

func SetTimezone(tz ...string)

SetTimezone 设置时区,默认上海

func TimeDifference added in v1.8.68

func TimeDifference(t1, t2 string) (time.Duration, error)

TimeDifference 计算两个时间字符串之间的时间间隔

Types

This section is empty.

Jump to

Keyboard shortcuts

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