times

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DaySecond  int64 = 24 * 60 * 60
	WeekSecond int64 = DaySecond * 7
)

Variables

This section is empty.

Functions

func Format

func Format(layout ...string) string

func GetTimeZone

func GetTimeZone() string

func Now

func Now() time.Time

func SetTimeZone

func SetTimeZone(zone string)

func Sign

func Sign(addDays int) (sign int32, str string)

func String

func String() string

func TimeReset

func TimeReset(v [3]int)

func Unix

func Unix() int64

func Verify

func Verify(et ExpireType, v int64) (r bool)

Verify 验证是否有效,true:有效

Types

type ExpireType

type ExpireType int8
const (
	ExpireTypeNone      ExpireType = 0
	ExpireTypeDaily     ExpireType = 1
	ExpireTypeWeekly    ExpireType = 2
	ExpireTypeMonthly   ExpireType = 3
	ExpireTypeSecond    ExpireType = 4
	ExpireTypeCustomize ExpireType = 5
)

type Times

type Times struct {
	WeekStartDay int //每周开始时间,默认周一   1:周一,0:周日
	// contains filtered or unexported fields
}

func Add

func Add(d time.Duration) *Times

func AddDate

func AddDate(years int, months int, days int) *Times

func Daily

func Daily(addDays int) *Times

Daily 获取一天的开始时间 addDays:天偏移,0:今天凌晨,1:明天凌晨 args :时,分,秒,毫秒

func Expire

func Expire(t ExpireType, v int) (ttl *Times, err error)

func Monthly

func Monthly(addMonth int) *Times

Monthly 获取本月开始时间 addMonth:月偏移,0:本月,1:下月 -1:上月

func New

func New(v ...time.Time) *Times

func Parse

func Parse(value string, layout ...string) (*Times, error)

func Timestamp

func Timestamp(v int64) *Times

func Weekly

func Weekly(addWeeks int) *Times

Weekly 获取本周开始时间 addWeeks:周偏移,0:本周,1:下周 -1:上周

func (*Times) Add

func (this *Times) Add(d time.Duration) *Times

func (*Times) AddDate

func (this *Times) AddDate(years int, months int, days int) *Times

func (*Times) Daily

func (this *Times) Daily(addDays int) *Times

Daily 获取一天的开始时间 addDays:天偏移,0:今天凌晨,1:明天凌晨 args :时,分,秒,毫秒

func (*Times) Expire

func (this *Times) Expire(t ExpireType, v int) (ttl *Times, err error)

Expire 过期时间

func (*Times) Format

func (this *Times) Format(layout ...string) string

func (*Times) GetTimeZone

func (this *Times) GetTimeZone() string

func (*Times) Monthly

func (this *Times) Monthly(addMonth int) *Times

Monthly 获取本月开始时间 addMonth:月偏移,0:本月,1:下月 -1:上月

func (*Times) New

func (this *Times) New(v ...time.Time) *Times

func (*Times) Now

func (this *Times) Now() time.Time

func (*Times) Parse

func (this *Times) Parse(value string, layout ...string) (*Times, error)

func (*Times) SetTimeZone

func (this *Times) SetTimeZone(zone string)

func (*Times) Sign

func (this *Times) Sign(addDays int) (sign int32, str string)

func (*Times) String

func (this *Times) String() string

func (*Times) TimeReset

func (this *Times) TimeReset(v [3]int)

func (*Times) Timestamp

func (this *Times) Timestamp(v int64) *Times

func (*Times) Unix

func (this *Times) Unix() int64

func (*Times) Verify

func (this *Times) Verify(t ExpireType, v int64) (r bool)

Verify 验证是否有效,true:有效

func (*Times) Weekly

func (this *Times) Weekly(addWeeks int) *Times

Weekly 获取本周开始时间 addWeeks:周偏移,0:本周,1:下周 -1:上周

Jump to

Keyboard shortcuts

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