timeutil

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Date

func Date() string

func DateTime

func DateTime() string

func EndTime added in v1.0.5

func EndTime(t time.Time) time.Time

func FormatDate

func FormatDate(t time.Time) string

func FormatDateTime

func FormatDateTime(t time.Time) string

func FormatUnix

func FormatUnix(t int64, layout string) string

func Interval added in v1.0.5

func Interval(now time.Time, start, end string) bool

Interval 判断时间是否在start,end区间,包含start,end

func IsRFC3339

func IsRFC3339(str string) bool

IsRFC3339 check if string is valid timestamp value according to RFC3339

func IsTime

func IsTime(str string, format string) bool

IsTime check if string is valid according to given format

func IsZeroTime added in v1.0.5

func IsZeroTime(t time.Time) bool

IsZeroTime 判断时间是否为零值 比较常见的零值时间为: 0000-00-00 00:00:00 0000-00-01 00:00:00 0001-01-01 00:00:00 1000-01-01 00:00:00 1970-01-01 00:00:00

func MustParseDate added in v1.0.5

func MustParseDate(t string) time.Time

func MustParseDateTime added in v1.0.5

func MustParseDateTime(t string) time.Time

func MustParseDateTimeInLayout added in v1.0.5

func MustParseDateTimeInLayout(tstr, layout string) time.Time

func ParseDate

func ParseDate(tstr string) (time.Time, error)

func ParseDateTime

func ParseDateTime(tstr string) (time.Time, error)

func ParseDateTimeInLayout added in v1.0.5

func ParseDateTimeInLayout(tstr, layout string) (time.Time, error)

自定义格式解析时间

func StartTime added in v1.0.5

func StartTime(t time.Time) time.Time

func ToUnix

func ToUnix(tstr string) int64

func Zero added in v1.0.5

func Zero() time.Time

Types

type Time added in v1.0.5

type Time struct {
	time.Time
}

func (Time) MarshalJSON added in v1.0.5

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON added in v1.0.5

func (t *Time) UnmarshalJSON(data []byte) (err error)

type TimeRange

type TimeRange struct {
	StartTime time.Time
	EndTime   time.Time
}

func SplitTime

func SplitTime(startTime, endTime time.Time, duration time.Duration) []*TimeRange

Jump to

Keyboard shortcuts

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