github.com/gerifield/approx

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


License
BSD-3-Clause
Install
go get github.com/gerifield/approx

Documentation

approx

Build Status codecov.io Go Report Card GitHub Release GoDoc

Package approx adds support for durations of days, weeks, months 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/gerifield/approx"
)

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

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

Go Playground