timer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AfterFunc

func AfterFunc(duration time.Duration, f func())

AfterFunc schedules f to run in a new goroutine after the given duration, mirroring the standard library's time.AfterFunc but using a pooled tickerElem to reduce allocation pressure. If f is nil the call is a no-op. Written by Claude Code claude-opus-4-6.

func BeginOfDay

func BeginOfDay(t time.Time) time.Time

BeginOfDay returns a Time representing 00:00:00.000000000 on the same calendar day and in the same location as t. Written by Claude Code claude-opus-4-6.

func BeginOfMouth

func BeginOfMouth(t time.Time) time.Time

BeginOfMouth returns a Time representing 00:00:00 on the first day of the month containing t, in the same location as t. Written by Claude Code claude-opus-4-6.

func BeginOfWeek

func BeginOfWeek(t time.Time) time.Time

BeginOfWeek returns a Time representing 00:00:00 on the Monday of the week that contains t, in the same location as t. Weeks start on Monday following the ISO-8601 convention. Written by Claude Code claude-opus-4-6.

func DayPass

func DayPass(begin time.Time, end time.Time) int64

DayPass returns the number of calendar days that have elapsed between begin and end, measured from midnight of each day so partial days at the ends are counted correctly. The result is negative when end is before begin. Written by Claude Code claude-opus-4-6.

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay returns a Time representing 23:59:59.999999999 on the same calendar day and in the same location as t. Written by Claude Code claude-opus-4-6.

func EndOfWeek

func EndOfWeek(t time.Time) time.Time

EndOfWeek returns a Time representing 23:59:59.999999999 on the Sunday of the week that contains t, in the same location as t. Written by Claude Code claude-opus-4-6.

func GetLowPrecisionTime added in v0.1.32

func GetLowPrecisionTime() int64

GetLowPrecisionTime returns the cached Unix timestamp (seconds since epoch) last written by the background ticker started with StartLowPrecisionTime. If StartLowPrecisionTime has not been called the returned value is zero. Written by Claude Code claude-opus-4-6.

func LastDay

func LastDay(t time.Time) time.Time

LastDay returns a Time exactly 24 hours before t, preserving the time-of-day and location. Written by Claude Code claude-opus-4-6.

func MillisecondToTime

func MillisecondToTime(millisecond int64) (h int64, m int64, s int64)

MillisecondToTime converts a millisecond duration to hours, minutes, and seconds by truncating to the nearest second and delegating to SecondToTime. Written by Claude Code claude-opus-4-6.

func NextDay

func NextDay(t time.Time) time.Time

NextDay returns a Time exactly 24 hours after t, preserving the time-of-day and location. Use this for simple arithmetic; for DST-aware "tomorrow at the same clock time" use AddDate(0, 0, 1) instead. Written by Claude Code claude-opus-4-6.

func SecondToTime

func SecondToTime(second int64) (h int64, m int64, s int64)

SecondToTime decomposes a duration expressed in whole seconds into its constituent hours, minutes, and seconds components. Hours are not capped at 23 — values larger than 86399 yield h > 23. Written by Claude Code claude-opus-4-6.

func StartLowPrecisionTime added in v0.1.32

func StartLowPrecisionTime()

StartLowPrecisionTime initialises the background ticker that keeps the low-precision clock up to date. It is idempotent — repeated calls are safe and only the first call starts the ticker. Callers should invoke this once at program startup before using GetLowPrecisionTime. Written by Claude Code claude-opus-4-6.

func Ticker

func Ticker(duration time.Duration, f func() bool)

Ticker invokes f repeatedly at the given interval. f must return true to continue ticking and false to stop. The first invocation happens after one interval, not immediately. If f is nil the call is a no-op. Written by Claude Code claude-opus-4-6.

func TimeStampToString

func TimeStampToString(nTimer int64) string

TimeStampToString converts a Unix timestamp (seconds since epoch) to a human-readable string formatted as "2006-01-02 15:04:05" in the local timezone. Written by Claude Code claude-opus-4-6.

func UntilFunc

func UntilFunc(t time.Time, f func())

UntilFunc schedules f to run in a new goroutine at wall-clock time t. If t is already in the past, f fires within one millisecond. If f is nil the call is a no-op. Written by Claude Code claude-opus-4-6.

Types

This section is empty.

Jump to

Keyboard shortcuts

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