Skip to content

Instantly share code, notes, and snippets.

@riza
Last active January 1, 2017 22:11
Show Gist options
  • Save riza/478893f0861016a087b9df37edfbc589 to your computer and use it in GitHub Desktop.
Save riza/478893f0861016a087b9df37edfbc589 to your computer and use it in GitHub Desktop.
Go ISO8601 Package Gists
testDuration := "P1Y2DT3H4M5S"
durationFromString, err := duration.FromString(testDuration)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Years: %v \n",durationFromString.Years) // Years: 1
fmt.Printf("Days: %v \n",durationFromString.Days) // Days: 2
fmt.Printf("Hours: %v \n",durationFromString.Hours) // Hours: 3
fmt.Printf("Minutes: %v \n",durationFromString.Minutes) // Minutes: 4
fmt.Printf("Seconds: %v \n",durationFromString.Seconds) // Seconds: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment