Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 869 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 869 Bytes

gohumantime

A human readable time translator in golang

GoDoc

Motivation

Use a simple human readable string representation of time Inspired by: https://github.com/rschmukler/human-interval

Usage:

import "github.com/urjitbhatia/gohumantime"
//...
millis, err := gohumantime.ToMilliseconds("1 day and 14 hours")

millis, err := gohumantime.ToMilliseconds("9981234314")
// If string is numeric, unit is assumed to be Milliseconds and a simple atoi conversion is returned.
//...

Benchmarks

  //3000 samples of ToMilliseconds("4 seconds, 2 minutes 1 hour and 3 days and 10weeks, 1 month and 1 year"):

  Ran 3000 samples:
  runtime:
    Fastest Time: 0.000s
    Slowest Time: 0.001s
    Average Time: 0.000s ± 0.000s