time

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

time

Documentation

Index

Constants

View Source
const (
	DateDelta   = 693594 // Days between 1/1/0001 and 12/31/1899
	HoursPerDay = 24
	MinsPerHour = 60
	SecsPerMin  = 60
	MSecsPerSec = 1000

	MinsPerDay  = HoursPerDay * MinsPerHour
	SecsPerHour = SecsPerMin * MinsPerHour
	SecsPerDay  = MinsPerDay * SecsPerMin
	MSecsPerDay = SecsPerDay * MSecsPerSec

	OneMillisecond  = FPCDateTime(1) / MSecsPerDay
	HalfMilliSecond = OneMillisecond / 2

	JulianEpoch = FPCDateTime(-2415018.5)
	UnixEpoch   = JulianEpoch + FPCDateTime(2440587.5)

	ApproxDaysPerMonth = 30.4375
	ApproxDaysPerYear  = 365.25
)

Variables

View Source
var (
	Year   = "2006"
	Month  = "01"
	Day    = "02"
	Hour   = "15"
	Minute = "04"
	Second = "05"

	FmtYMdHmsSSS = "2006-01-02 15:04:05.000"
	FmtYMdHmsS   = "2006-01-02 15:04:05.0"
	FmtYMdHms    = "2006-01-02 15:04:05"
	FmtYMdHm     = "2006-01-02 15:04"
	FmtYMdH      = "2006-01-02 15"
	FmtYMd       = "2006-01-02"
	FmtYM        = "2006-01"
	FmtY         = "2006"
	FmtYYYYMMdd  = "20060102"

	FmtHmsSSSMore = "15:04:05.000000000"
	FmtHmsSSS     = "15:04:05.000"
	FmtHms        = "15:04:05"
	FmtHm         = "15:04"
	FmtH          = "15"

	EmptyTime = t0.Time{}
)

Functions

func AddDays added in v1.0.0

func AddDays(times t0.Time, days int) t0.Time

func AddHour added in v1.0.0

func AddHour(times t0.Time, plusOrMinus string, seconds string) t0.Time

func AddMinutes added in v1.0.0

func AddMinutes(times t0.Time, plusOrMinus string, minutes string) t0.Time

func AddMonths added in v1.0.0

func AddMonths(times t0.Time, month int) t0.Time

func AddSeconds added in v1.0.0

func AddSeconds(times t0.Time, plusOrMinus string, hours string) t0.Time

func AddYears added in v1.0.0

func AddYears(times t0.Time, year int) t0.Time

func CurrentMinuteOfDay added in v0.7.0

func CurrentMinuteOfDay() int

func CurrentSecondOfDay added in v0.7.0

func CurrentSecondOfDay() int

func DaySpan added in v0.7.0

func DaySpan(now, then t0.Time) float64

func DaysBetween added in v0.7.0

func DaysBetween(now, then t0.Time) int

func HourSpan added in v0.7.0

func HourSpan(now, then t0.Time) float64

func HoursBetween added in v0.7.0

func HoursBetween(now, then t0.Time) int

func IsLeapYear added in v0.7.0

func IsLeapYear(year int) bool

func IsTimeEmpty added in v1.0.0

func IsTimeEmpty(time t0.Time) bool

func MilliSecondSpan added in v0.7.0

func MilliSecondSpan(now, then t0.Time) int64

func MilliSecondsBetween added in v0.7.0

func MilliSecondsBetween(now, then t0.Time) int64

func MinuteOfDay added in v0.7.0

func MinuteOfDay(t t0.Time) int

func MinuteSpan added in v0.7.0

func MinuteSpan(now, then t0.Time) float64

func MinutesBetween added in v0.7.0

func MinutesBetween(now, then t0.Time) int

func MinutesToTime added in v0.7.0

func MinutesToTime(minutes int) (hour int, minute int)

func MonthSpan added in v0.7.0

func MonthSpan(now, then t0.Time) float64

func MonthsBetween added in v0.7.0

func MonthsBetween(now, then t0.Time) int

func Now added in v0.9.0

func Now() t0.Time

func NumToTimeDuration added in v1.0.12

func NumToTimeDuration(num int, duration t0.Duration) t0.Duration

func ParseTime added in v1.0.0

func ParseTime(timeStr string) t0.Time

func ParseTimeYmsHms

func ParseTimeYmsHms(timeStr string) (t0.Time, error)

func ParseTimeYmsHmsLoc

func ParseTimeYmsHmsLoc(timeStr string, loc *t0.Location) (t0.Time, error)

func ParseTimeYmsHmsS

func ParseTimeYmsHmsS(timeStr string) (t0.Time, error)

func ParseTimeYmsHmsSLoc

func ParseTimeYmsHmsSLoc(timeStr string, loc *t0.Location) (t0.Time, error)

func SecondOfDay added in v0.7.0

func SecondOfDay(t t0.Time) int

func SecondSpan added in v0.7.0

func SecondSpan(now, then t0.Time) float64

func SecondsBetween added in v0.7.0

func SecondsBetween(now, then t0.Time) int

func SecondsToTime added in v0.7.0

func SecondsToTime(seconds int) (hour int, minute int, second int)

func TimeInMicro added in v0.7.0

func TimeInMicro() int64

TimeInMicro 16位时间戳

func TimeInMillis added in v0.7.0

func TimeInMillis() int64

TimeInMillis 13位java时间戳

func TimeInNano added in v0.7.0

func TimeInNano() int64

TimeInNano 19位时间戳

func TimeInSeconds added in v0.7.0

func TimeInSeconds() int64

TimeInSeconds 10位Unix时间戳

func TimeToStringFormat

func TimeToStringFormat(t t0.Time, format string) string

func TimeToStringYmdHms

func TimeToStringYmdHms(t t0.Time) string

func TimeToStringYmdHmsS

func TimeToStringYmdHmsS(t t0.Time) string

func WithInPastDays added in v0.7.0

func WithInPastDays(now, then t0.Time, days int) bool

func WithInPastHours added in v0.7.0

func WithInPastHours(now, then t0.Time, hours int) bool

func WithInPastMilliSeconds added in v0.7.0

func WithInPastMilliSeconds(now, then t0.Time, milliSeconds int64) bool

func WithInPastMinutes added in v0.7.0

func WithInPastMinutes(now, then t0.Time, minutes int) bool

func WithInPastMonths added in v0.7.0

func WithInPastMonths(now, then t0.Time, months int) bool

func WithInPastSeconds added in v0.7.0

func WithInPastSeconds(now, then t0.Time, seconds int) bool

func WithInPastYears added in v0.7.0

func WithInPastYears(now, then t0.Time, years int) bool

func YearSpan added in v0.7.0

func YearSpan(now, then t0.Time) float64

func YearsBetween added in v0.7.0

func YearsBetween(now, then t0.Time) int

Types

type FPCDateTime added in v0.7.0

type FPCDateTime float64

type OnTimerFunc added in v1.0.7

type OnTimerFunc func(t *Timer)

type Timer added in v1.0.7

type Timer struct {
	Interval      int64
	IsStopped     bool
	OnTimer       OnTimerFunc // 这个函数将在[协程]内异步调用
	OnBeforeTimer OnTimerFunc // 这个函数在[主线程]内同步调用
	OnAfterTimer  OnTimerFunc // 这个函数在[主线程]内同步调用
	// contains filtered or unexported fields
}

func NewTimer added in v1.0.7

func NewTimer() *Timer

func NewTimerWithFire added in v1.0.7

func NewTimerWithFire(seconds float64, onTimer OnTimerFunc) *Timer

func NewTimerWithInterval added in v1.0.7

func NewTimerWithInterval(seconds float64) *Timer

func (*Timer) SetInterval added in v1.0.7

func (t *Timer) SetInterval(seconds float64)

func (*Timer) SetOnAfter added in v1.0.7

func (t *Timer) SetOnAfter(event OnTimerFunc)

func (*Timer) SetOnBefore added in v1.0.7

func (t *Timer) SetOnBefore(event OnTimerFunc)

func (*Timer) SetOnTimer added in v1.0.7

func (t *Timer) SetOnTimer(event OnTimerFunc)

func (*Timer) Start added in v1.0.7

func (t *Timer) Start()

func (*Timer) Stop added in v1.0.7

func (t *Timer) Stop()

Jump to

Keyboard shortcuts

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