Documentation
¶
Overview ¶
Package duration provides a partial implementation of ISO8601 durations. (no months)
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBadFormat is returned when parsing fails ErrBadFormat = errors.New("bad format string") ErrWeeksNotWithYearsOrMonth = errors.New("weeks are not allowed with years or months") ErrMonthsInDurationUseOverload = errors.New("months are not allowed with the ToDuration method, use the overload instead") )
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration struct { Years int Months int Weeks int Days int Hours int Minutes int Seconds int MilliSeconds int }
func FromString ¶
func (*Duration) HasTimePart ¶
func (*Duration) Normalize ¶ added in v0.0.17
Normalize makes sure that all fields are represented as the smallest meaningful value possible by dividing them out by the conversion factor to the larger unit. e.g. if you have a duration of 10 day, 25 hour, and 61 minute, it will be normalized to 1 week 5 days, 2 hours, and 1 minute. this function does not normalize days to months, weeks to months or weeks to years as they do not always convert with the same value. it also won't normalize days to weeks if months or years are present, and will return an error if the value is invalid
Click to show internal directories.
Click to hide internal directories.