twins

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 1 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 twins holds the cases that the dashboard's server and its script must word alike. The script, in ui/static, keeps the words that the server put on a page up to date, so each of its word functions has a twin in the server's Go: ago, span, and visible. The tests of package ui run the Go functions through these cases, and the browser tests, in ui/browsertest, run the script's.

Index

Constants

This section is empty.

Variables

View Source
var Ago = []struct {
	Before time.Duration
	Want   string
}{
	{0, "now"},
	{900 * time.Millisecond, "now"},
	{901 * time.Millisecond, "1s ago"},
	{time.Second, "1s ago"},
	{59 * time.Second, "59s ago"},
	{time.Minute, "1m ago"},
	{59 * time.Minute, "59m ago"},
	{time.Hour, "1h ago"},
	{47 * time.Hour, "47h ago"},
	{48 * time.Hour, "2d ago"},
	{-99 * time.Millisecond, "now"},
	{-100 * time.Millisecond, "in 1s"},
	{-time.Second, "in 1s"},
	{-59 * time.Second, "in 59s"},
	{-time.Minute, "in 1m"},
	{-59 * time.Minute, "in 59m"},
	{-time.Hour, "in 1h"},
	{-47 * time.Hour, "in 47h"},
	{-48 * time.Hour, "in 2d"},
}

Ago are the words of a relative time: of a time Before Now, or after it for a negative Before. Both times are read to the second, as a clock shows them, so every relative time of a page changes on the second.

View Source
var Now = time.Date(2026, time.November, 19, 12, 0, 0, 900_000_000, time.UTC)

Now is the time of rendering of the cases of Ago.

View Source
var Span = []struct {
	D    time.Duration
	Want string
}{
	{-time.Second, "0s"},
	{0, "0s"},
	{time.Microsecond, "<1ms"},
	{999 * time.Microsecond, "<1ms"},
	{time.Millisecond, "1ms"},
	{35 * time.Millisecond, "35ms"},
	{999 * time.Millisecond, "999ms"},
	{time.Second, "1s"},
	{1300 * time.Millisecond, "1.3s"},
	{1999 * time.Millisecond, "1.9s"},
	{2 * time.Second, "2s"},
	{9999 * time.Millisecond, "9.9s"},
	{10 * time.Second, "10s"},
	{10900 * time.Millisecond, "10s"},
	{59*time.Second + 999*time.Millisecond, "59s"},
	{time.Minute, "1m"},
	{time.Minute + time.Second, "1m 1s"},
	{time.Hour - time.Second, "59m 59s"},
	{time.Hour, "1h"},
	{time.Hour + 59*time.Second, "1h"},
	{time.Hour + time.Minute, "1h 1m"},
	{24 * time.Hour, "24h"},
	{48*time.Hour - time.Second, "47h 59m"},
	{48 * time.Hour, "2d"},
	{49 * time.Hour, "2d 1h"},
	{400 * 24 * time.Hour, "400d"},
}

Span are the words of a length of time: to the tenth of a second below a second, and to the second above it, in two units at most, each cut down, so "1.9s" is no whole second more than "1s". The script counts only the gaps that last until now, in whole seconds: it words the cases of whole seconds.

View Source
var Visible = []struct {
	Name, Want string
}{
	{"plain", "plain"},
	{"orders\x1fkey", "orders␟key"},
	{"\x00\t\n\x1b", "␀␉␊␛"},
	{"del\x7f", "del␡"},
	{"next\u0085line", "next<U+0085>line"},
	{"mail\u202eliam", "mail<U+202E>liam"},
	{"pay\u200bment", "pay<U+200B>ment"},
	{"\ufeffbom", "<U+FEFF>bom"},
	{"tag\U000E0041", "tag<U+E0041>"},
	{"\u0600sign", "<U+0600>sign"},
	{"pay\u034fments", "pay<U+034F>ments"},
	{"\u3164filler", "<U+3164>filler"},
	{"blank\u2800", "blank<U+2800>"},
	{"heart\ufe0f", "heart<U+FE0F>"},
	{"ivs\U000E0100", "ivs<U+E0100>"},
	{"no\u00a0break", "no<U+00A0>break"},
	{"ideo\u3000space", "ideo<U+3000>space"},
	{"line\u2028end", "line<U+2028>end"},
	{" lead", "␠lead"},
	{"trail ", "trail␠"},
	{"two  spaces", "two␠␠spaces"},
	{" ", "␠"},
	{"one space", "one space"},
	{"cafe\u0301 \U0001F600 \u2603", "cafe\u0301 \U0001F600 \u2603"},
}

Visible are names with characters that no one could see, or tell from a space, as a page shows them: a control character, or a space that HTML would fold away or that ends the name, as its Unicode control picture where it has one, and any other, a format or default-ignorable character, or another space, as its code point.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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