Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 1, 2026. It is now read-only.
/ duration Public archive

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

6 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

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /