v0.0.0-...-87682d9 Latest Latest

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 14



Package clock displays a clock.



This section is empty.


This section is empty.


This section is empty.


type Module

type Module struct {
	// contains filtered or unexported fields

Module represents a clock bar module. It supports setting the click handler, timezone, output format, and granularity.

func Local

func Local() *Module

Local constructs a clock module for the current machine's timezone.

func Zone

func Zone(timezone *time.Location) *Module

Zone constructs a clock module for the given timezone.

func ZoneByName

func ZoneByName(name string) (*Module, error)

ZoneByName constructs a clock module for the given zone name, (e.g. "America/Los_Angeles"), and returns any errors.

func (*Module) Output

func (m *Module) Output(
	granularity time.Duration,
	outputFunc func(time.Time) bar.Output,
) *Module

Output configures a module to display the output of a user-defined function.

The first argument configures the granularity at which the module should refresh. For example, if the format does not have seconds, it should be time.Minute.

The module will always update at the next second, minute, hour, etc., so large granularities will not negatively affect the output due to drift.

Additionally, the module will automatically update when discontinuous change of clock occurs, due to e.g. system suspend or clock adjustments.

func (*Module) OutputFormat

func (m *Module) OutputFormat(format string) *Module

OutputFormat configures a module to display the time in a given format.

func (*Module) Stream

func (m *Module) Stream(s bar.Sink)

Stream starts the module.

func (*Module) Timezone

func (m *Module) Timezone(timezone *time.Location) *Module

Timezone configures the timezone for this clock.

Jump to

Keyboard shortcuts

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