Skip to content

Copy of stdlib's time.Duration, but ParseDuration accepts other bigger units such as days, weeks, months and years

Notifications You must be signed in to change notification settings

caarlos0/duration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duration

Copy of stdlib's time.Duration, but ParseDuration accepts other units as well:

  • d: days (24 * time.Hour)
  • w: weeks (7 * Day)
  • mo: months (30 * Day)
  • y: years (365 * Day)

This is specially useful if you want to accept duration as flags in your program, and those duration are expected to be high. Asking the user to type 7860h instead of 1y might be something you don't want to. If so, you can accept the flag as string and parse with this package instead.

Hopefully, someday, something like this gets merged into the stdlib.

About

Copy of stdlib's time.Duration, but ParseDuration accepts other bigger units such as days, weeks, months and years

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages