Documentation ¶
Overview ¶
Package duration provides a partial implementation of ISO8601 durations. Constant values are assumed for non-constant timespans for convenience 1 Day = 24 Hours 1 Month = 30 Days 1 Year = 365 Days
Index ¶
- Constants
- Variables
- type Duration
- func (d *Duration) Days() float64
- func (d *Duration) HasTimePart() bool
- func (d *Duration) Hours() float64
- func (d *Duration) IsWeeksOnly() bool
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d *Duration) Minutes() float64
- func (d *Duration) Seconds() float64
- func (d *Duration) String() string
- func (d *Duration) ToDuration() time.Duration
- func (d *Duration) UnmarshalJSON(data []byte) error
- func (d *Duration) Weeks() float64
- func (d *Duration) Years() float64
Constants ¶
Variables ¶
View Source
var ( // ErrBadFormat is returned when parsing fails ErrBadFormat = errors.New("bad format string") )
Functions ¶
This section is empty.
Types ¶
type Duration ¶
func ParseString ¶
func (*Duration) HasTimePart ¶
func (*Duration) IsWeeksOnly ¶
func (Duration) MarshalJSON ¶
func (*Duration) String ¶
String prints out the value passed in. It's not strictly according to the ISO spec, but it's pretty close. In particular, months are not returned. Instead, it returns a value in days (1D ~ 364D) or weeks (1W ~ 52W) whenever possible.
func (*Duration) ToDuration ¶
func (*Duration) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.