timex

package
v0.0.0-...-cd938e1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocationAsiaShanghai = MustLoadLocation("Asia/Shanghai")
View Source
var Zero = time.Date(0, 1, 1, 0, 0, 0, 0, time.UTC)

Functions

func BeginOfDay

func BeginOfDay(now time.Time) time.Time

func BeginOfMonth

func BeginOfMonth(now time.Time) time.Time

func BeginOfWeek

func BeginOfWeek(now time.Time) time.Time

获取周一

func DiffDays

func DiffDays(t1, t2 time.Time) int

计算两个日期相差多少天

func FromProtoTimestamp

func FromProtoTimestamp(ts *timestamp.Timestamp) time.Time

转换为time.Time

func IsSameDate

func IsSameDate(t1, t2 time.Time) bool

计算两个日期是否相等

func MustLoadLocation

func MustLoadLocation(name string) *time.Location

func MustParse

func MustParse(layout, value string) time.Time

func MustParseDuration

func MustParseDuration(s string) time.Duration

func MustParseInLocation

func MustParseInLocation(layout, value string, loc *time.Location) time.Time

func NumOfWeek

func NumOfWeek(now time.Time) int

获取周中数字

func ParseProtoTimestamp

func ParseProtoTimestamp(layout, value string) *timestamp.Timestamp

解析日期时间字符串并转换为proto.Timestamp 比如:timex.ParseProtoTimestamp("2006-01-02T15:04:05.000Z", stringDateTimeRFC3339),

func ToProtoTimestamp

func ToProtoTimestamp(tm time.Time) *timestamp.Timestamp

转换为proto.Timestamp

Types

This section is empty.

Jump to

Keyboard shortcuts

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