strftime

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 4 Imported by: 0 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 strftime formats lys-shell's strftime-style format strings. The clock and other time-bearing modules take user formats in strftime syntax; Go layouts are never user-facing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Layout

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

Layout is a compiled strftime format: validated once at load, then formatted per tick without re-parsing.

func Compile

func Compile(format string) (*Layout, error)

Compile validates a strftime format. Unsupported or dangling specifiers are errors — a bad format fails at load instead of rendering garbage at runtime.

func (*Layout) Format

func (l *Layout) Format(t time.Time) string

Format renders t through the compiled format. Literal text passes through unchanged; "%%" renders a single percent sign. A chrono padding flag between the percent and the specifier re-pads numeric fields: "-" drops the padding (%-d is "5"), "_" pads with spaces, "0" with zeros; on text fields the flag changes nothing, as in chrono.

func (*Layout) Resolution added in v0.2.0

func (l *Layout) Resolution() time.Duration

Resolution is how often the rendered text can change: a second with a seconds field in the format, otherwise a minute.

func (*Layout) String

func (l *Layout) String() string

String returns the source format.

Jump to

Keyboard shortcuts

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