duration

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeDay   = 24 * time.Hour
	TimeMonth = 30 * TimeDay
	TimeYear  = 365 * TimeDay
)

time values for missing time values

Variables

This section is empty.

Functions

func Format added in v1.3.0

func Format(duration time.Duration) string

Format returns a string representing the duration in the ISO 8601 format, but only with the hours being the highest time element, e.g. "PT44H7M3.15s". Leading zero units are omitted. The result counts as a valid ISO8601 duration. It supports negative durations, as detailed in the extension ISO 8601-2.

func FormatQuick added in v1.1.0

func FormatQuick(duration time.Duration) string

FormatQuick Deprecated: use FormatSeconds instead.

func FormatSeconds added in v1.2.0

func FormatSeconds(duration time.Duration) string

FormatSeconds returns a string representing the duration in the ISO8601 format, but only in seconds, e.g. "PT345.15s". Leading zero units are omitted. The result counts as a valid ISO8601 duration. It supports negative durations, as detailed in the extension ISO8601-2. Deprecated: it is not significantly faster than Format, so it will be replaced by it later.

func ParseToDuration

func ParseToDuration(durationString string) (time.Duration, error)

ParseToDuration parses an ISO 8601 duration string into a time.Duration. It accepts negative durations but only by prepending a '-' like: "[-]P<duration>".

Types

This section is empty.

Jump to

Keyboard shortcuts

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