Documentation ¶
Index ¶
- Constants
- func CalcNextSec(sec int) int
- func CalcNextSecWithTime(t time.Time, sec int) int
- func Date(year int, month time.Month, day int) time.Time
- func DateWithHMS(year int, month time.Month, day, hour, min, sec int) time.Time
- func GetDayZero(t time.Time, day int) time.Time
- func GetDeltaDay(t1, t2 time.Time) int
- func GetDeltaWeek(t1, t2 time.Time) int
- func GetHSMFromString(timeStr, layout string) (hour, min, sec int)
- func GetMondayZero(t time.Time) time.Time
- func GetMonthDays(t time.Time) int
- func GetNextDayInterval(t time.Time) time.Duration
- func GetSecond(d time.Duration) int
- func GetTimeFromString(timeStr, layout string) time.Time
- func GetToday(t time.Time) time.Time
- func IntervalFormat(time1, time2 time.Time) string
- func IntervalFormatSet(intervalType int, str string)
- func IsSameDay(t1, t2 time.Time) bool
- func IsSameHour(t1, t2 time.Time) bool
- func WeekDay(t time.Time) int
- type Period
- func NewPeriod(start, end time.Time) Period
- func NewPeriodWithDay(t time.Time, day int) Period
- func NewPeriodWithDayZero(t time.Time, day int) Period
- func NewPeriodWithHour(t time.Time, hour int) Period
- func NewPeriodWithMicrosecond(t time.Time, microsecond int) Period
- func NewPeriodWithMillisecond(t time.Time, millisecond int) Period
- func NewPeriodWithMinute(t time.Time, minute int) Period
- func NewPeriodWithNanosecond(t time.Time, nanosecond int) Period
- func NewPeriodWithSecond(t time.Time, second int) Period
- func NewPeriodWithTimeArray(times [2]time.Time) Period
- func (slf Period) Day() int
- func (slf Period) Duration() time.Duration
- func (slf Period) End() time.Time
- func (slf Period) Hour() int
- func (slf Period) IsAfter(t time.Time) bool
- func (slf Period) IsBefore(t time.Time) bool
- func (slf Period) IsBetween(t time.Time) bool
- func (slf Period) IsBetweenOrEqual(t time.Time) bool
- func (slf Period) IsBetweenOrEqualPeriod(t Period) bool
- func (slf Period) IsInvalid() bool
- func (slf Period) IsOngoing(t time.Time) bool
- func (slf Period) IsOverlap(t Period) bool
- func (slf Period) IsZero() bool
- func (slf Period) Microseconds() int
- func (slf Period) Milliseconds() int
- func (slf Period) Minute() int
- func (slf Period) Nanoseconds() int
- func (slf Period) Seconds() int
- func (slf Period) Start() time.Time
Constants ¶
const ( IntervalYear = iota IntervalDay IntervalHour IntervalMinute IntervalSecond IntervalNow )
const ( Nanosecond = time.Nanosecond Microsecond = time.Microsecond Millisecond = time.Millisecond Second = time.Second Minute = time.Minute Hour = time.Hour Day = time.Hour * 24 Week = Day * 7 )
Variables ¶
This section is empty.
Functions ¶
func CalcNextSecWithTime ¶
CalcNextSecWithTime 计算下一个N秒在多少秒之后
func DateWithHMS ¶ added in v0.0.2
DateWithHMS 返回一个精确到秒的时间
func GetDayZero ¶ added in v0.0.3
GetDayZero 获取 t 增加 day 天后的零点时间
func GetDeltaWeek ¶ added in v0.0.2
GetDeltaWeek 获取两个时间需要加减的周数
func GetHSMFromString ¶ added in v0.0.2
GetHSMFromString 从时间字符串中获取时分秒
func GetNextDayInterval ¶
GetNextDayInterval 获取一个时间到下一天间隔多少秒
func GetTimeFromString ¶ added in v0.0.2
GetTimeFromString 将时间字符串转化为时间
func IntervalFormatSet ¶
IntervalFormatSet 针对 IntervalFormat 函数设置格式化内容
Types ¶
type Period ¶ added in v0.0.3
Period 表示一个时间段
func NewPeriodWithDay ¶ added in v0.0.3
NewPeriodWithDay 创建一个时间段,从 t 开始,持续 day 天
func NewPeriodWithDayZero ¶ added in v0.0.3
NewPeriodWithDayZero 创建一个时间段,从 t 开始,持续到 day 天后的 0 点
func NewPeriodWithHour ¶ added in v0.0.3
NewPeriodWithHour 创建一个时间段,从 t 开始,持续 hour 小时
func NewPeriodWithMicrosecond ¶ added in v0.0.3
NewPeriodWithMicrosecond 创建一个时间段,从 t 开始,持续 microsecond 微秒
func NewPeriodWithMillisecond ¶ added in v0.0.3
NewPeriodWithMillisecond 创建一个时间段,从 t 开始,持续 millisecond 毫秒
func NewPeriodWithMinute ¶ added in v0.0.3
NewPeriodWithMinute 创建一个时间段,从 t 开始,持续 minute 分钟
func NewPeriodWithNanosecond ¶ added in v0.0.3
NewPeriodWithNanosecond 创建一个时间段,从 t 开始,持续 nanosecond 纳秒
func NewPeriodWithSecond ¶ added in v0.0.3
NewPeriodWithSecond 创建一个时间段,从 t 开始,持续 second 秒
func NewPeriodWithTimeArray ¶ added in v0.0.3
NewPeriodWithTimeArray 创建一个时间段
func (Period) IsBetweenOrEqual ¶ added in v0.0.3
IsBetweenOrEqual 判断指定时间是否在时间段之间或者等于时间段的开始或结束时间
func (Period) IsBetweenOrEqualPeriod ¶ added in v0.0.3
IsBetweenOrEqualPeriod 判断指定时间是否在时间段之间或者等于时间段的开始或结束时间
func (Period) IsOngoing ¶ added in v0.0.3
IsOngoing 判断指定时间是否正在进行时
- 如果时间段的开始时间在指定时间之前或者等于指定时间,且时间段的结束时间在指定时间之后,则返回 true
func (Period) Microseconds ¶ added in v0.0.3
Microseconds 返回时间段的持续微秒数
func (Period) Milliseconds ¶ added in v0.0.3
Milliseconds 返回时间段的持续毫秒数
func (Period) Nanoseconds ¶ added in v0.0.3
Nanoseconds 返回时间段的持续纳秒数