Documentation
¶
Overview ¶
Package duration parses RFC3339 duration strings into time.Duration
Installation ¶
Just go get the package:
go get -u github.com/peterhellberg/duration
Usage ¶
A small usage example
package main import ( "fmt" "github.com/peterhellberg/duration" ) func main() { if d, err := duration.Parse("P1DT30H4S"); err == nil { fmt.Println(d) // Output: 54h0m4s } }
Index ¶
Examples ¶
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 ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.