format

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package format renders the small values the CLI and the dashboard both print: durations, large counts and a book's metadata line. They live here so `oku timer` and the TUI cannot drift apart, and so neither has to import the other.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookMeta

func BookMeta(b model.Book) string

BookMeta is the one-line summary under a book: rating, readers, release date and series, in that order, joined by " · ". Parts with no data are omitted, so an unrated book gets a shorter line rather than an empty one.

func Clock

func Clock(t time.Time) string

Clock is the time of day a session started, in the reader's own zone: 24-hour, no seconds. Sessions are listed one per row against a date, so the hour is all that distinguishes them.

func Count

func Count(n int) string

Count abbreviates a large count so it fits a list row: 1234 → "1.2K".

func DayLabel

func DayLabel(t, now time.Time) string

DayLabel names the day t falls on, relative to now: "Today", "Yest.", or the date. Both are bucketed to local midnight, so a session at 23:50 and one at 00:10 read as different days even though they are twenty minutes apart, and a session logged late in the evening is not "yesterday" because UTC has already rolled over.

func Duration

func Duration(d time.Duration) string

Duration renders a duration at the coarsest unit that still says something:

Duration(2*time.Hour + 5*time.Minute) → "2h 5m"
Duration(90*time.Second)              → "1m 30s"
Duration(9*time.Second)               → "9s"

func Thousands

func Thousands(n int) string

Thousands formats an int with thousands separators: 1748 → "1,748".

Types

This section is empty.

Jump to

Keyboard shortcuts

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