Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.11 KB

README.md

File metadata and controls

49 lines (34 loc) · 1.11 KB

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
}