timefix

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//MILLISECONDS_OF_DAY 一天的毫秒数
	MILLISECONDS_OF_DAY = 24 * MILLISECONDS_OF_HOUR
	//MILLISECONDS_OF_HOUR 一小时的毫秒数
	MILLISECONDS_OF_HOUR = 60 * MILLISECONDS_OF_MINUTE
	//MILLISECONDS_OF_MINUTE 一分钟的毫秒数
	MILLISECONDS_OF_MINUTE = 60 * MILLISECONDS_OF_SECOND
	//MILLISECONDS_OF_SECOND 一秒的毫秒数
	MILLISECONDS_OF_SECOND = 1000
)

Variables

View Source
var (
	//TimeFormate 时间格式
	TimeFormate string = "2006-01-02 15:04:05"

	SIMPLE_DAY_FORMAT string = "2006-01-02"
	//TimeFix 时差修正 纳秒差值
	TimeFix int64
	//Server_Location 服务器使用的标准时区
	Server_Location = time.Local
)

Functions

func AvgTime

func AvgTime(items []time.Duration) time.Duration

func BytesFormat

func BytesFormat(bytes uint64) string

format bytes number friendly

func CheckCrossDay

func CheckCrossDay(baset time.Time, now time.Time) bool

CheckCrossDay 检查是否跨天

func CheckCrossMonth

func CheckCrossMonth(baset time.Time, now time.Time) bool

CheckCrossMonth 检查是否跨月

func CheckCrossWeek

func CheckCrossWeek(baset time.Time, now time.Time) bool

CheckCrossWeek 检查是否跨周

func CurrentMS

func CurrentMS() int64

CurrentMS 当前本地时间 毫秒 已修正

func CurrentTime

func CurrentTime() time.Time

CurrentTime 服务器当前时间

func DeltaDays

func DeltaDays(unix1, unix2 int64) int64

DeltaDays 获取两个时间跨了多少天 >=0

func GetDayInMon

func GetDayInMon(year int, mon int) int

GetDayInMon 获取月份的天数

func MillisTime

func MillisTime() int64

MillisTime 当前本地时间 毫秒 已修正

func Nanos2Time

func Nanos2Time(ns int64) time.Time

Nanos2Time 纳秒时间转成服务器时间(根据传入的时间的时区在返回的时间上进行时区纠正time.Time().In(tm.Location()))

func NanosTime

func NanosTime() int64

NanosTime 当前本地时间 纳秒 已修正

func NextHour

func NextHour(tm time.Time) time.Time

NextHour 从一个时间戳获取下一个准点时间

func NextHours

func NextHours(tm time.Time, n int) time.Time

NextHours 从一个时间戳获取下一个准点时间

func NextMidnight

func NextMidnight(tm time.Time, day int) time.Time

NextMidnight 获取一个时间点的 x日后的凌晨时间

func NextSundayMS

func NextSundayMS(tm time.Time) time.Time

NextSundayMS 获取指定时间的下一个周末时间,自己处理好时区的问题,周一凌晨作为跨周,如果传入的时间没有超过周一凌晨,则返回周一凌晨的时间点,否则返回下一周的周一凌晨

func NowToSharpClock

func NowToSharpClock(tm time.Time) time.Duration

NowToSharpClock 返回从整点到现在的差值

func ResetTime

func ResetTime(t int64)

ResetTime 重置时间,传入utc标准时间UnixNano()

func S2UnixTime

func S2UnixTime(value string, loc *time.Location) (*time.Time, error)

S2UnixTime date format: "2006-01-02 15:04:05"

func Second2Time

func Second2Time(second int64) time.Time

Second2Time 秒时间转成服务器时间(根据传入的时间的时区在返回的时间上进行时区纠正time.Time().In(tm.Location()))

func SecondTime

func SecondTime() int64

SecondTime 当前本地时间 秒 已修正

func SharpClock

func SharpClock(tm time.Time) time.Time

SharpClock 返回当前的整点时间

func ShortTimeFormat

func ShortTimeFormat(d time.Duration) string

short string format

func Time2Midnight

func Time2Midnight(tm time.Time) time.Time

Time2Midnight 获得指定时间的凌晨时间

func TimeMillis

func TimeMillis(t time.Duration) int64

TimeMillis 时间转成毫秒

func TimeSecond

func TimeSecond(t time.Duration) int64

TimeSecond 时间转成秒

Types

This section is empty.

Jump to

Keyboard shortcuts

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