Skip to content

xescugc/duration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duration

GoDoc

This package offers the ability to parse a string to a time.Duration. It's more strict (specific order and no repetition) than the time.ParseDuration but it offers more options: y (year), w (week) and d(day).

It also has those durations as constants so: duration.Year, duration.Week and duration.Day

Install

go get github.com/xescugc/duration

API

Parse(s string) (time.Duration, error)

Parse parses a duration string with the following formats:

  • y(year)
  • w(week)
  • d(day)
  • h(hour)
  • m(minute)
  • s(second)
  • ms(millisecond)
  • us or µs(microsecond)
  • ns(nanosecond).

The order of the string is strict, must be from 'larger' to 'lesser', so '1m1s' is correct but '1s1m' is not, and repetitions are not permitted, '1s1s' is invalid.

About

This package offers the hability to parse a string to a time.Duration

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages