Skip to content

Library that extends time.Duration from standard library with days, months and years

License

Notifications You must be signed in to change notification settings

akramarenkov/whilst

Repository files navigation

Whilst

Go Reference Go Report Card Coverage Status

Purpose

Library that extends time.Duration from standard library with days, months and years

Features

Without approximations

Allows for presence of spaces in a string representation

Compatible with time.Duration in terms of parsing and conversion to string

Usage

Example:

package main

import (
    "fmt"
    "time"

    "github.com/akramarenkov/whilst"
)

func main() {
    from := time.Date(2023, time.April, 1, 0, 0, 0, 0, time.UTC)

    whl, err := whilst.Parse("2y")
    if err != nil {
        panic(err)
    }

    fmt.Println(whl)
    fmt.Println(whl.When(from))
    fmt.Println(whl.Duration(from))
    // Output:
    // 2y
    // 2025-04-01 00:00:00 +0000 UTC
    // 17544h0m0s
}

About

Library that extends time.Duration from standard library with days, months and years

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages