Copy of stdlib's time.Duration, but ParseDuration accepts other bigger units such as days, weeks, months and years

Overview

duration

Copy of stdlib's time.Duration, but ParseDuration accepts other units as well:

  • d: days (7 * 24 * time.Hour)
  • w: weeks (7 * Day)
  • mo: months (30 * Day)
  • y: years (365 * Day)

This is specially useful if you want to accept duration as flags in your program, and those duration are expected to be high. Asking the user to type 7860h instead of 1y might be something you don't want to. If so, you can accept the flag as string and parse with this package instead.

Hopefully, someday, something like this gets merged into the stdlib.

You might also like...
🌐 A time zone helper
🌐 A time zone helper

🌐 A time zone helper tz helps you schedule things across time zones. It is an interactive TUI program that displays time across a few time zones of y

Clock is a small library for mocking time in Go.

clock Clock is a small library for mocking time in Go. It provides an interface around the standard library's time package so that the application can

A natural language date/time parser with pluggable rules

when when is a natural language date/time parser with pluggable rules and merge strategies Examples tonight at 11:10 pm at Friday afternoon the deadli

time format golang

a simple plugin to change date and time format

Structural time package for jalali calendar

Jalali Structural time package for jalali calendar. This package support parse from string, json and time. Structures There are three data structures

Show time by timezone

Show time by timezone

Timediff is a Go package for printing human readable, relative time differences 🕰️

timediff is a Go package for printing human readable, relative time differences. Output is based on ranges defined in the Day.js JavaScript library, and can be customized if needed.

Go-timeparser - Flexible Time Parser for Golang

go-timeparser Flexible Time Parser for Golang Installation Download timeparser w

Gesetzliche Feiertage und mehr in Deutschland und Österreich (Bank holidays/public holidays in Austria and Germany)

Feiertage Feiertage is a Go/Golang library for calculating German and Austrian bank holidays. It includes the calculation of the date of Easter and, m

Owner
Carlos Alexandro Becker
Creator @goreleaser; SRE @totvslabs; I try to delete more code than I write.
Carlos Alexandro Becker
52 weeks, 52 Go projects

Project52 Golang Challenge A project to write a small project everyweek. All projects are written by Golang. Preface: I saw a slide reflectionsfrom 52

Evan Lin 1.3k Jan 2, 2023
Convert string to duration in golang

Go String To Duration (go-str2duration) This package allows to get a time.Duration from a string. The string can be a string retorned for time.Duratio

Santiago De la Cruz 57 Dec 7, 2022
Time struct in Go that uses 4 bytes of memory vs the 24 bytes of time.Time

A tiny time object in Go. Tinytime uses 4 bytes of memory vs the 24 bytes of a standard time.Time{}

Lane Wagner 59 Oct 3, 2022
:clock1: Date and Time - Golang Formatting Library

Kair Date and Time - Golang Formatting Library Setup To get Kair > Go CLI go get github.com/GuilhermeCaruso/kair > Go DEP dep ensure -add github.com/G

Guilherme Caruso 24 Sep 26, 2022
Carbon for Golang, an extension for Time

Carbon A simple extension for Time based on PHP's Carbon library. Features: Time is embedded into Carbon (provides access to all of Time's functionali

Uniplaces LTD 742 Dec 20, 2022
Now is a time toolkit for golang

Now Now is a time toolkit for golang Install go get -u github.com/jinzhu/now Usage Calculating time based on current time import "github.com/jinzhu/n

Jinzhu 4k Dec 23, 2022
Golang package to manipulate time intervals.

timespan timespan is a Go library for interacting with intervals of time, defined as a start time and a duration. Documentation API Installation Insta

null 82 Sep 26, 2022
timeutil - useful extensions (Timedelta, Strftime, ...) to the golang's time package

timeutil - useful extensions to the golang's time package timeutil provides useful extensions (Timedelta, Strftime, ...) to the golang's time package.

Kyoung-chan Lee 190 Dec 22, 2022
Go time library inspired by Moment.js

Goment Current Version: 1.4.0 Changelog Goment is a port of the popular Javascript datetime library Moment.js. It follows the Moment.js API closely, w

Nick Leeper 209 Dec 24, 2022
fasttime - fast time formatting for go

fasttime - fast time formatting for go

phuslu 67 Dec 13, 2022