Awesome Go

approx

CategoryDate and Time
SubcategoryDate and Time
Stars0

A Duration extension supporting parsing/printing durations in days, weeks and years

About 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

Frequently Asked Questions

What is approx?

approx is a Date and Time library for the Go programming language. A Duration extension supporting parsing/printing durations in days, weeks and years

How do I install approx?

Install approx with the Go module system using `go get goschtalt/approx`. Check the repository for the current installation instructions.

What category does approx belong to?

approx is listed under Date and Time, specifically Date and Time.

← Back to Date and Time