Skip to content

About

Parse '1h30m' style durations to seconds and back — dependency-free.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Duration parse/format

duration.go

Check out the Go Duration test right next to the implementation to see it in action.

We frequently need to convert strings like '1h30m' into seconds and back again. This module handles that exact conversion without pulling in extra dependencies, which keeps your environment clean and predictable.

The implementation relies strictly on the Go standard library. You do not need to install any external services or third-party packages to get this running.

Common questions

Why is there no client library in the dependencies?
You really do not need one. The operation is just a single HTTPS request inside duration.go, and go run . handles all the tooling. When you are just parsing durations, keeping the dependency tree empty is the whole point.

How much of this is reusable?
duration.go is the only piece you actually want to copy into your own codebase. The rest of the files just exist so this example runs as a standalone script.

About

Parse '1h30m' style durations to seconds and back — dependency-free.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages