iso8601

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 7 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadFormat is returned when parsing fails
	ErrBadFormat = errors.New("bad format string")
)

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
}

func FromString

func FromString(dur string) (*Duration, error)

func (*Duration) Add added in v0.3.0

func (d *Duration) Add(t time.Time) time.Time

func (*Duration) HasTimePart

func (d *Duration) HasTimePart() bool

func (*Duration) IsZero added in v0.3.0

func (d *Duration) IsZero() bool

func (*Duration) RelativeTo added in v0.3.0

func (d *Duration) RelativeTo(t time.Time) time.Duration

func (*Duration) String

func (d *Duration) String() string

String prints out the value passed in. It's not strictly according to the ISO spec, but it's pretty close. In particular, to completely conform it would need to round up to the next largest unit. 61 seconds to 1 minute 1 second, for example. It would also need to disallow weeks mingling with other units.

Jump to

Keyboard shortcuts

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