durations

package module
v0.0.0-...-9ff18e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 4 Imported by: 0

README

1. Go Durations

Go Report Card PkgGoDev

1.1. What is this for

Go Durations easily parse string durations without any order in input order and high durations like 1 year.

1.2. Why

I was looking for parser with out any order on string, easy to use, support long term durations such as year, month. I couldn't find so I created one.

1.3. Usage

Duration, Err := GetDuration("1mon 1w 1h 1m 1s")

Duration, Err := GetDuration("1h 1w 1m 1y")

1.4. All Durations

Durations short Package
Nanosecond ns Time.Time
Microsecond us & µs & μs Time.Time
Millisecond ms Time.Time
Second s Time.Time
Minute m Time.Time
Hour h Time.Time
Day d durations
Week w durations
Month mon durations
Year y durations
Century c durations

1.5. Credit

ElecTwix

Documentation

Index

Constants

View Source
const (
	Nanosecond  Duration = 1
	Microsecond          = 1000 * Nanosecond
	Millisecond          = 1000 * Microsecond
	Second               = 1000 * Millisecond
	Minute               = 60 * Second
	Hour                 = 60 * Minute
	Day                  = 24 * Hour
	Week                 = 7 * Day
	Month                = 30 * Day
	Year                 = 365 * Day
	Century              = 100 * Year
)

Variables

This section is empty.

Functions

func GetDuration

func GetDuration(durationstr string) (totalduration time.Duration, err error)

func GetTotalLeapYear

func GetTotalLeapYear(totalyear int) (duration time.Duration)

Types

type Duration

type Duration int64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL