barista.run: barista.run/modules/clock Index | Files

package clock

import "barista.run/modules/clock"

Package clock displays a clock.

Index

Package Files

clock.go

type Module Uses

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 Uses

func Local() *Module

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

func Zone Uses

func Zone(timezone *time.Location) *Module

Zone constructs a clock module for the given timezone.

func ZoneByName Uses

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 Uses

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.

func (*Module) OutputFormat Uses

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

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

func (*Module) Stream Uses

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

Stream starts the module.

func (*Module) Timezone Uses

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

Timezone configures the timezone for this clock.

Package clock imports 8 packages (graph) and is imported by 3 packages. Updated 2018-12-22. Refresh now. Tools for package owners.