time

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 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

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

func AddHour

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

func AddMinutes

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

func AddMonths

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

func AddSeconds

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

func AddYears

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

func CurrentMinuteOfDay

func CurrentMinuteOfDay() int

func CurrentSecondOfDay

func CurrentSecondOfDay() int

func DaySpan

func DaySpan(now, then t0.Time) float64

func DaysBetween

func DaysBetween(now, then t0.Time) int

func HourSpan

func HourSpan(now, then t0.Time) float64

func HoursBetween

func HoursBetween(now, then t0.Time) int

func IsLeapYear

func IsLeapYear(year int) bool

func IsTimeEmpty

func IsTimeEmpty(time t0.Time) bool

func MilliSecondSpan

func MilliSecondSpan(now, then t0.Time) int64

func MilliSecondsBetween

func MilliSecondsBetween(now, then t0.Time) int64

func MinuteOfDay

func MinuteOfDay(t t0.Time) int

func MinuteSpan

func MinuteSpan(now, then t0.Time) float64

func MinutesBetween

func MinutesBetween(now, then t0.Time) int

func MinutesToTime

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

func MonthSpan

func MonthSpan(now, then t0.Time) float64

func MonthsBetween

func MonthsBetween(now, then t0.Time) int

func Now

func Now() t0.Time

func NumToTimeDuration

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

func ParseTime

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

func SecondOfDay(t t0.Time) int

func SecondSpan

func SecondSpan(now, then t0.Time) float64

func SecondsBetween

func SecondsBetween(now, then t0.Time) int

func SecondsToTime

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

func TimeInMicro

func TimeInMicro() int64

TimeInMicro 16位时间戳

func TimeInMillis

func TimeInMillis() int64

TimeInMillis 13位java时间戳

func TimeInNano

func TimeInNano() int64

TimeInNano 19位时间戳

func TimeInSeconds

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

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

func WithInPastHours

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

func WithInPastMilliSeconds

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

func WithInPastMinutes

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

func WithInPastMonths

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

func WithInPastSeconds

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

func WithInPastYears

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

func YearSpan

func YearSpan(now, then t0.Time) float64

func YearsBetween

func YearsBetween(now, then t0.Time) int

Types

type FPCDateTime

type FPCDateTime float64

type OnTimerFunc

type OnTimerFunc func(t *Timer)

type Timer

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

func NewTimer

func NewTimer() *Timer

func NewTimerWithFire

func NewTimerWithFire(seconds float64, onTimer OnTimerFunc) *Timer

func NewTimerWithInterval

func NewTimerWithInterval(seconds float64) *Timer

func (*Timer) SetInterval

func (t *Timer) SetInterval(seconds float64)

func (*Timer) SetOnAfter

func (t *Timer) SetOnAfter(event OnTimerFunc)

func (*Timer) SetOnBefore

func (t *Timer) SetOnBefore(event OnTimerFunc)

func (*Timer) SetOnTimer

func (t *Timer) SetOnTimer(event OnTimerFunc)

func (*Timer) Start

func (t *Timer) Start()

func (*Timer) Stop

func (t *Timer) Stop()

Jump to

Keyboard shortcuts

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