times

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntervalYear = iota
	IntervalDay
	IntervalHour
	IntervalMinute
	IntervalSecond
	IntervalNow
)
View Source
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 CalcNextSec

func CalcNextSec(sec int) int

CalcNextSec 计算下一个N秒在多少秒之后

func CalcNextSecWithTime

func CalcNextSecWithTime(t time.Time, sec int) int

CalcNextSecWithTime 计算下一个N秒在多少秒之后

func Date added in v0.0.2

func Date(year int, month time.Month, day int) time.Time

Date 返回一个特定日期的时间

func DateWithHMS added in v0.0.2

func DateWithHMS(year int, month time.Month, day, hour, min, sec int) time.Time

DateWithHMS 返回一个精确到秒的时间

func GetDeltaDay added in v0.0.2

func GetDeltaDay(t1, t2 time.Time) int

GetDeltaDay 获取两个时间需要加减的天数

func GetDeltaWeek added in v0.0.2

func GetDeltaWeek(t1, t2 time.Time) int

GetDeltaWeek 获取两个时间需要加减的周数

func GetHSMFromString added in v0.0.2

func GetHSMFromString(timeStr, layout string) (hour, min, sec int)

GetHSMFromString 从时间字符串中获取时分秒

func GetMondayZero

func GetMondayZero(t time.Time) time.Time

GetMondayZero 获取本周一零点

func GetMonthDays

func GetMonthDays(t time.Time) int

GetMonthDays 获取一个时间当月共有多少天

func GetNextDayInterval

func GetNextDayInterval(t time.Time) time.Duration

GetNextDayInterval 获取一个时间到下一天间隔多少秒

func GetSecond

func GetSecond(d time.Duration) int

GetSecond 获取共有多少秒

func GetTimeFromString added in v0.0.2

func GetTimeFromString(timeStr, layout string) time.Time

GetTimeFromString 将时间字符串转化为时间

func GetToday

func GetToday(t time.Time) time.Time

GetToday 获取一个时间的今天

func IntervalFormat

func IntervalFormat(time1, time2 time.Time) string

IntervalFormat 返回指定时间戳之间的间隔

  • 使用传入的时间进行计算换算,将结果体现为几年前、几天前、几小时前、几分钟前、几秒前。

func IntervalFormatSet

func IntervalFormatSet(intervalType int, str string)

IntervalFormatSet 针对 IntervalFormat 函数设置格式化内容

func IsSameDay

func IsSameDay(t1, t2 time.Time) bool

IsSameDay 两个时间是否是同一天

func IsSameHour

func IsSameHour(t1, t2 time.Time) bool

IsSameHour 两个时间是否是同一小时

func WeekDay

func WeekDay(t time.Time) int

WeekDay 获取一个时间是星期几

  • 1 ~ 7

Types

This section is empty.

Jump to

Keyboard shortcuts

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