wallclock

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wallclock is the time a clock on screen shows, which unlike the timers of the runtime is what the user reads off their wall: it moves on through a suspend, and jumps when NTP or an administrator sets it or the time zone changes.

Index

Constants

View Source
const LocaltimePath = "/etc/localtime"

LocaltimePath is the file the machine's time zone is set in.

Variables

This section is empty.

Functions

This section is empty.

Types

type SystemClock

type SystemClock struct {
	// contains filtered or unexported fields
}

SystemClock is the wall clock of this machine. An absolute timer on CLOCK_REALTIME fires on the wall clock's time however long the machine slept, and TFD_TIMER_CANCEL_ON_SET fails its read the moment the clock is set; a watch on the zone file reloads the zone, which the runtime only reads once. With TZ set the zone is the one TZ names, and the file is not watched.

func NewSystemClock

func NewSystemClock(invoke func(func()), zonePath string) (*SystemClock, error)

NewSystemClock starts a clock that follows the zone set in zonePath and runs what is armed through invoke, on the loop.

func (*SystemClock) Arm

func (c *SystemClock) Arm(at time.Time, fn func())

Arm runs fn on the loop when the wall clock reaches at, or at once when it or the zone jumps, replacing what was armed.

func (*SystemClock) Close

func (c *SystemClock) Close() error

Close stops the clock; nothing armed runs after it.

func (*SystemClock) Disarm

func (c *SystemClock) Disarm()

Disarm forgets what was armed; a firing on its way finds nothing.

func (*SystemClock) Now

func (c *SystemClock) Now() time.Time

Now is the time in the current zone.

Directories

Path Synopsis
Package wallclocktest sets the time zone a wallclock.SystemClock under test watches.
Package wallclocktest sets the time zone a wallclock.SystemClock under test watches.

Jump to

Keyboard shortcuts

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