time

package
v0.0.0-...-4b81ff1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MPL-2.0 Imports: 6 Imported by: 3

Documentation

Overview

Package time parses RFC3339 duration strings into time.Duration taken from https://github.com/peterhellberg/duration

Index

Constants

View Source
const (
	// HoursPerDay is the number of hours per day according to Google
	HoursPerDay = 24.0

	// HoursPerWeek is the number of hours per week according to Google
	HoursPerWeek = 168.0

	// HoursPerMonth is the number of hours per month according to Google
	HoursPerMonth = 730.4841667

	// HoursPerYear is the number of hours per year according to Google
	HoursPerYear = 8765.81
)

Variables

View Source
var (
	// ErrInvalidString is returned when passed an invalid string
	ErrInvalidString = fmt.Errorf("invalid duration string")

	// ErrUnsupportedFormat is returned when parsing fails
	ErrUnsupportedFormat = fmt.Errorf("unsupported duration string format")
)

Functions

This section is empty.

Types

type ISODuration

type ISODuration string

ISODuration - iso representation of

func ParseDuration

func ParseDuration(s string) (*ISODuration, error)

ParseDuration a RFC3339 duration string into time.Duration

func (*ISODuration) From

func (i *ISODuration) From(t time.Time) (*time.Time, error)

From - return a time relative to a given time based on the ISODuration

func (*ISODuration) FromNow

func (i *ISODuration) FromNow() (*time.Time, error)

FromNow - add this isoduration to time.Now, resulting in a new time

func (*ISODuration) String

func (i *ISODuration) String() string

String - implement stringer

Jump to

Keyboard shortcuts

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