Documentation ¶
Index ¶
- Constants
- func FormatUnix(timestamp int64, layout string) string
- func FormatUnixDate(timestamp int64) string
- func FormatUnixDateTime(timestamp int64) string
- func IsLeap(year int) bool
- func Jitter(n int64, factor ...float64) (scale int64)
- func JitterTime(d time.Duration, factor ...float64) (scale time.Duration)
- type Time
- func (t *Time) BeginOfDay() *Time
- func (t *Time) BeginOfHour() *Time
- func (t *Time) BeginOfMinute() *Time
- func (t *Time) BeginOfMonth() *Time
- func (t *Time) BeginOfWeek() *Time
- func (t *Time) BeginOfYear() *Time
- func (t *Time) CurrentMilliTime() int64
- func (t *Time) CurrentNanoTime() int64
- func (t *Time) CurrentUnixTime() int64
- func (t *Time) DaysAfter(days int) *Time
- func (t *Time) DaysBefore(days int) *Time
- func (t *Time) EndOfDay() *Time
- func (t *Time) EndOfHour() *Time
- func (t *Time) EndOfMinute() *Time
- func (t *Time) EndOfMonth() *Time
- func (t *Time) EndOfWeek() *Time
- func (t *Time) EndOfYear() *Time
- func (t *Time) Format(layout string) string
- func (t *Time) Leap() bool
- func (t *Time) Tomorrow() *Time
- func (t *Time) Yesterday() *Time
Constants ¶
const ( RFC3339Format = time.RFC3339 DateFormat = "2006-01-02" DateTimeFormat = "2006-01-02 15:04:05" TimeFormat = "15:04:05" ShortDateTimeFormat = "20060102150405" ShortDateFormat = "20060102" ShortTimeFormat = "150405" DaysPerLeapYear = 366 // 每闰年366天 DaysPerNormalYear = 365 // 每常规年365天 MonthsPerYear = 12 // 每年12月 MonthsPerQuarter = 3 // 每季度3月 DaysPerNormalMonth = 30 // 单月30天 DaysPerDoubleMonth = 31 // 双月31天 DaysOfNormalFebruary = 28 // 二月28天 DaysOfLeapFebruary = 29 // 闰年二月29天 DaysPerWeek = 7 // 每周7天 HoursPerDay = 24 // 每天24小时 MinutesPerDay = 1440 // 每天1440分钟 MinutesPerHour = 60 // 每小时60分钟 SecondsPerDay = 86400 // 每天86400秒 SecondsPerHour = 3600 // 每小时3600秒 SecondsPerMinute = 60 // 每分钟60秒 MillisecondsPerSecond = 1000 // 每秒1000毫秒 )
Variables ¶
This section is empty.
Functions ¶
func FormatUnix ¶ added in v1.3.3
FormatUnix formats Unix timestamp to layout string
func FormatUnixDate ¶ added in v1.0.0
FormatUnixDate formats Unix timestamp to date string
func FormatUnixDateTime ¶ added in v1.0.0
FormatUnixDateTime formats Unix timestamp to time string
func Jitter ¶ added in v1.3.5
Jitter simulates jitter by scaling a integer randomly within factor The duration d must be greater than zero; and the scaling factor must be within the range 0 < factor <= 1.0, default factor is 0.1
func JitterTime ¶ added in v1.3.5
JitterTime simulates jitter by scaling a time.Duration randomly within factor The duration d must be greater than zero; and the scaling factor must be within the range 0 < factor <= 1.0, default factor is 0.1
Types ¶
type Time ¶ added in v1.0.0
func DaysBefore ¶ added in v1.3.3
DaysBefore returns a days-ago Time instance of current time
func ParseByLayout ¶ added in v1.3.3
ParseByLayout parses a string as a Time instance by layout
func Tomorrow ¶ added in v1.3.3
func Tomorrow() *Time
Tomorrow returns a tomorrow Time instance of current time
func Yesterday ¶ added in v1.3.3
func Yesterday() *Time
Yesterday returns a yesterday Time instance of current time
func (*Time) BeginOfDay ¶ added in v1.0.0
BeginOfDay return begin time of current day
func (*Time) BeginOfHour ¶ added in v1.0.0
BeginOfHour return begin time of current hour
func (*Time) BeginOfMinute ¶ added in v1.0.0
BeginOfMinute return begin second of current minute
func (*Time) BeginOfMonth ¶ added in v1.0.0
BeginOfMonth return begin day time of current month
func (*Time) BeginOfWeek ¶ added in v1.0.0
BeginOfWeek return begin day time of current week NOTE: week begin from Sunday
func (*Time) BeginOfYear ¶ added in v1.0.0
BeginOfYear return the beginning time of current year
func (*Time) CurrentMilliTime ¶ added in v1.0.0
GetCurrentMilliTime return current milliseconds
func (*Time) CurrentNanoTime ¶ added in v1.0.0
GetCurrentNanoTime return current nano seconds
func (*Time) CurrentUnixTime ¶ added in v1.0.0
GetCurrentUnixTime return current unix seconds
func (*Time) DaysBefore ¶ added in v1.3.3
DaysBefore returns a days-ago Time instance of assigned t
func (*Time) EndOfMinute ¶ added in v1.0.0
EndOfMinute return end second of current minute
func (*Time) EndOfMonth ¶ added in v1.0.0
EndOfMonth return end day time of current month
func (*Time) EndOfWeek ¶ added in v1.0.0
EndOfWeek return end day time of current week NOTE: week end with Saturday
func (*Time) Format ¶ added in v1.0.0
Format returns a textual representation of the time value formatted according to layout