Skip to content

Package approx adds support for durations of days, weeks and years.

License

Notifications You must be signed in to change notification settings

goschtalt/approx

approx

Build Status codecov.io Go Report Card GitHub Release GoDoc

Package approx adds support for durations of days, weeks and years. The code used is from the go standard library. Only very minor adjustments were made to enable parsing to support extra units of time.

Usage

This really simple library allows you to normally use the time.Duration object from the go standard library, but suppliments two functions for handling approximate time durations.

package main

import (
	"fmt"

	"github.com/goschtalt/approx"
)

func main() {
	d, err := approx.ParseDuration("1w4d")
	if err != nil {
		panic(err)
	}

	fmt.Println(approx.String(d))
	fmt.Println(d)
}

Go Playground

About

Package approx adds support for durations of days, weeks and years.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages