humanreltime

package module
v0.0.0-...-794c2e8 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2017 License: BSD-3-Clause Imports: 4 Imported by: 1

README

go-humanreltime

Convert timespans to strings for human consumption. Currently supports only German, other languages should be easy to implement.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var German = Language{
	Name:     "Deutsch",
	LangCode: "de",
	Now:      "jetzt",
	Prefix: Prefix{
		Negative: "vor ",
		Positive: "in ",
	},
	Suffix: map[Resolution]Suffix{
		Years: Suffix{
			Singular: "Jahr",
			Plural:   "Jahren",
		},
		Months: Suffix{
			Singular: "Monat",
			Plural:   "Monaten",
		},
		Weeks: Suffix{
			Singular: "Woche",
			Plural:   "Wochen",
		},
		Days: Suffix{
			Singular: "Tag",
			Plural:   "Tagen",
		},
		Hours: Suffix{
			Singular: "Stunde",
			Plural:   "Stunden",
		},
		Minutes: Suffix{
			Singular: "Minute",
			Plural:   "Minuten",
		},
		Seconds: Suffix{
			Singular: "Sekunde",
			Plural:   "Sekunden",
		},
	},
	Delimiter: Delimiter{
		Last: " und ",
		Rest: ", ",
	},
}

Functions

This section is empty.

Types

type Delimiter

type Delimiter struct {
	Last string
	Rest string
}

type Language

type Language struct {
	Name      string
	LangCode  string
	Now       string
	Suffix    map[Resolution]Suffix
	Prefix    Prefix
	Delimiter Delimiter
}

func (*Language) Duration

func (l *Language) Duration(timestamp time.Time, reference time.Time, maxRes Resolution, numComponents int) string

func (*Language) SuffixedNumber

func (l *Language) SuffixedNumber(number int64, res Resolution) string

type Prefix

type Prefix struct {
	Negative string
	Positive string
}

type Resolution

type Resolution uint8
const (
	Years Resolution = iota
	Months
	Weeks
	Days
	Hours
	Minutes
	Seconds
)

type Suffix

type Suffix struct {
	Singular string
	Plural   string
}

Jump to

Keyboard shortcuts

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