precisiondate

package
v4.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrecisionCentury = 7
	PrecisionDecade  = 8
	PrecisionYear    = 9
	PrecisionMonth   = 10
	PrecisionDay     = 11
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrecisionDate

type PrecisionDate struct {
	date.Date
	Precision float64
}

PrecisionDate implement a format for partially-known dates following Wikidata format. Some dates for relevant people are not fully known, for example, for Seneca, full birth and death dates are unknown, only the years. https://www.wikidata.org/wiki/Help:Dates

func NewPrecisionDate

func NewPrecisionDate(ISOdate string, precision float64) PrecisionDate

NewPrecisionDate parses a ISO 8601 formatted string and parses it into a PrecisionDate. As Wikidata dates come in different precision levels, we need to know what's the precision a date is using before parsing it, because dates in levels under day precision come with zero values for months or days, for example 2006-00-00. As this is not a valid ISO 8601, we need to convert it to a valid string beforehand.

func (PrecisionDate) Century

func (p PrecisionDate) Century() int

func (PrecisionDate) CenturyAbs

func (p PrecisionDate) CenturyAbs() int

func (PrecisionDate) FormatForLocale added in v4.9.0

func (p PrecisionDate) FormatForLocale(locale string) string

FormatForLocale returns an ISO format string for day precision dates, adapting to locale conventions.

func (PrecisionDate) IsPrecisionCentury

func (p PrecisionDate) IsPrecisionCentury() bool

func (PrecisionDate) IsPrecisionDay

func (p PrecisionDate) IsPrecisionDay() bool

func (PrecisionDate) IsPrecisionDecade

func (p PrecisionDate) IsPrecisionDecade() bool

func (PrecisionDate) IsPrecisionMonth

func (p PrecisionDate) IsPrecisionMonth() bool

func (PrecisionDate) IsPrecisionYear

func (p PrecisionDate) IsPrecisionYear() bool

Jump to

Keyboard shortcuts

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