_time

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFormat = "2006-01-02 15:04:05"
	DayFormat     = "2006-01-02"
	DayFormat1    = "2006/01/02"
	MonthFormat   = "2006-01"
	TzFormat      = "2006-01-02T15:04:05Z"
	TFormat       = "2006-01-02T15:04:05+08:00"
)
View Source
var TimeFormats = []string{"_1/2/2006", "_1/2/2006 15:4:5", "2006", "2006-_1", "2006-_1-2", "2006-_1-2 15", "2006-_1-2 15:4", "2006-_1-2 15:4:5", "_1-2", "15:4:5", "15:4", "15", "15:4:5 Jan 2, 2006 MST", "2006-01-02 15:04:05.999999999 -0700 MST", "2006-01-02T15:04:05-07:00"}

TimeFormats default time formats will be parsed as

View Source
var (
	TimeTemplate map[string]string = map[string]string{

		"timeTemplate1": "2006-01-02 15:04:05",
		"timeTemplate2": "2006/01/02 15:04:05",
		"timeTemplate3": "2006-01-02",
		"timeTemplate4": "15:04:05",
	}
)
View Source
var WeekStartDay = time.Monday

WeekStartDay set week start day, default is sunday

Functions

func AppointStamp64

func AppointStamp64(t time.Duration) (timestamp int64)

正确的使用方式 time.Sleep(time.Second * time.Duration(common.C.CpuTempRest)) 获取指定时间的时间戳 获取一个月之后的时间戳 30 * 24 * 60 * 60 * time.Second 或者 30 * 24 * time.Hour

func BeginningOfDay

func BeginningOfDay() time.Time

BeginningOfDay beginning of day

func BeginningOfHour

func BeginningOfHour() time.Time

BeginningOfHour beginning of hour

func BeginningOfMinute

func BeginningOfMinute() time.Time

BeginningOfMinute beginning of minute

func BeginningOfMonth

func BeginningOfMonth() time.Time

BeginningOfMonth beginning of month

func BeginningOfQuarter

func BeginningOfQuarter() time.Time

BeginningOfQuarter beginning of quarter

func BeginningOfWeek

func BeginningOfWeek() time.Time

BeginningOfWeek beginning of week

func BeginningOfYear

func BeginningOfYear() time.Time

BeginningOfYear beginning of year

func Between

func Between(time1, time2 string) bool

Between check now between the begin, end time or not

func EndOfDay

func EndOfDay() time.Time

EndOfDay end of day

func EndOfHour

func EndOfHour() time.Time

EndOfHour end of hour

func EndOfMinute

func EndOfMinute() time.Time

EndOfMinute end of minute

func EndOfMonth

func EndOfMonth() time.Time

EndOfMonth end of month

func EndOfQuarter

func EndOfQuarter() time.Time

EndOfQuarter end of quarter

func EndOfSunday

func EndOfSunday() time.Time

EndOfSunday end of sunday

func EndOfWeek

func EndOfWeek() time.Time

EndOfWeek end of week

func EndOfYear

func EndOfYear() time.Time

EndOfYear end of year

func Format

func Format(format string, ts ...time.Time) string

* 抄的https://github.com/polaris1119/times

Format 跟 PHP 中 date 类似的使用方式,如果 ts 没传递,则使用当前时间

func Int64ToString

func Int64ToString(t int64) string

将时间戳转换为字符串

func Monday

func Monday() time.Time

Monday monday

func MustParse

func MustParse(strs ...string) time.Time

MustParse must parse string to time or will panic

func MustParseInLocation

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

MustParseInLocation must parse string to time in location or will panic

func Parse

func Parse(strs ...string) (time.Time, error)

Parse parse string to time

func ParseInLocation

func ParseInLocation(loc *time.Location, strs ...string) (time.Time, error)

ParseInLocation parse string to time in location

func Stamp32

func Stamp32() (timestamp int)

获取时间戳 int32

func Stamp64

func Stamp64() int64

获取时间戳 int64

func StrToLocalTime

func StrToLocalTime(value string) time.Time

func StrToTime

func StrToTime(value string) time.Time

func String

func String(model string) string

获取当前时间字符串

func Sunday

func Sunday() time.Time

Sunday sunday

Types

type Now

type Now struct {
	time.Time
}

Now now struct

func New

func New(t time.Time) *Now

New initialize Now with time

func (*Now) BeginningOfDay

func (now *Now) BeginningOfDay() time.Time

BeginningOfDay beginning of day

func (*Now) BeginningOfHour

func (now *Now) BeginningOfHour() time.Time

BeginningOfHour beginning of hour

func (*Now) BeginningOfMinute

func (now *Now) BeginningOfMinute() time.Time

BeginningOfMinute beginning of minute

func (*Now) BeginningOfMonth

func (now *Now) BeginningOfMonth() time.Time

BeginningOfMonth beginning of month

func (*Now) BeginningOfQuarter

func (now *Now) BeginningOfQuarter() time.Time

BeginningOfQuarter beginning of quarter

func (*Now) BeginningOfWeek

func (now *Now) BeginningOfWeek() time.Time

BeginningOfWeek beginning of week

func (*Now) BeginningOfYear

func (now *Now) BeginningOfYear() time.Time

BeginningOfYear BeginningOfYear beginning of year

func (*Now) Between

func (now *Now) Between(begin, end string) bool

Between check time between the begin, end time or not

func (*Now) EndOfDay

func (now *Now) EndOfDay() time.Time

EndOfDay end of day

func (*Now) EndOfHour

func (now *Now) EndOfHour() time.Time

EndOfHour end of hour

func (*Now) EndOfMinute

func (now *Now) EndOfMinute() time.Time

EndOfMinute end of minute

func (*Now) EndOfMonth

func (now *Now) EndOfMonth() time.Time

EndOfMonth end of month

func (*Now) EndOfQuarter

func (now *Now) EndOfQuarter() time.Time

EndOfQuarter end of quarter

func (*Now) EndOfSunday

func (now *Now) EndOfSunday() time.Time

EndOfSunday end of sunday

func (*Now) EndOfWeek

func (now *Now) EndOfWeek() time.Time

EndOfWeek end of week

func (*Now) EndOfYear

func (now *Now) EndOfYear() time.Time

EndOfYear end of year

func (*Now) Monday

func (now *Now) Monday() time.Time

Monday monday

func (*Now) MustParse

func (now *Now) MustParse(strs ...string) (t time.Time)

MustParse must parse string to time or it will panic

func (*Now) Parse

func (now *Now) Parse(strs ...string) (t time.Time, err error)

Parse parse string to time

func (*Now) Sunday

func (now *Now) Sunday() time.Time

Sunday sunday

Jump to

Keyboard shortcuts

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