timefix

package
v0.0.0-...-29c100b Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

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

Variables

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

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

Functions

func CheckCrossDay

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

检查是否跨天

func CheckCrossMonth

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

检查是否跨月

func CheckCrossWeek

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

检查是否跨周

func CurrentTime

func CurrentTime() time.Time

服务器当前时间

func GetDayInMon

func GetDayInMon(year int, mon int) int

GetDayInMon 获取月份的天数

func GetTimeFormatString

func GetTimeFormatString(t time.Time) string

GetTimeFormatString 获取日期字符串

func Nanos2Time

func Nanos2Time(ns int64) time.Time

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

func NanosTime

func NanosTime() int64

当前本地时间 纳秒 已修正

func NextHour

func NextHour(tm time.Time) time.Time

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

func NextHours

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

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

func NextMidnight

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

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

func NextSundayMS

func NextSundayMS(tm time.Time) time.Time

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

func NowToSharpClock

func NowToSharpClock(tm time.Time) time.Duration

返回从整点到现在的差值

func OtherDay

func OtherDay(t1, t2 time.Time) bool

判断两个时间是否是同一天(默认将两个时间转换成0时区的时间进行比较)

func OtherDayByUnix

func OtherDayByUnix(t1, t2 int64) bool

判断两个时间是否是同一天(t1,t2为秒)

func ResetTime

func ResetTime(t int64)

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

func S2UnixTime

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

date format: "2006-01-02 13:04:00"

func Second2Time

func Second2Time(second int64) time.Time

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

func SecondTime

func SecondTime() int64

当前本地时间 秒 已修正

func SharpClock

func SharpClock(tm time.Time) time.Time

返回当前的整点时间

func Time2Midnight

func Time2Midnight(tm time.Time) time.Time

获得指定时间的凌晨时间

func TimeMillis

func TimeMillis(t time.Duration) int64

时间转成毫秒

func TimeSecond

func TimeSecond(t time.Duration) int64

时间转成秒

Types

This section is empty.

Jump to

Keyboard shortcuts

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