New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

github.com/the-control-group/go-timeutils

Package Overview
Dependencies
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/the-control-group/go-timeutils

Source
Go Modules
Version
v1.0.4
Version published
Created
Source

Go Timeutils

Usage


package main

import (
	"fmt"
	"encoding/json"
	"github.com/the-control-group/go-timeutils"
)

type Config struct {
	Duration timeutils.ApproxBigDuration `json:"duration"`
}

func main() {
	c := Config{}
	json.Unmarshal([]byte(`{"duration":"23 days"}`), &c)
    fmt.Println(c.Duration.String())
    fmt.Println(c.Duration.ApproxString())
    fmt.Println(c.Duration.Pretty())
    fmt.Println(c.Duration.ApproxPretty())
    fmt.Println(time.Duration(c.Duration))
}

// Output
// 23d0h 0s
// ~23d0h
// 23 days, 0 hours 0s
// ~ 23 days, 0 hours
// 552h0m0s

Caveats

  • ApproxBigDuration: There's a reason it's called "Approx[imate]BigDuration" and there's a reason go's time package doesn't have a unit for inexact durations like days, months and years.

FAQs

Package last updated on 18 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts