Skip to content

Golang package to return the elapsed time since a given time in a human readable format

License

Notifications You must be signed in to change notification settings

rvflash/elapsed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elapsed time

GoDoc Build Status Code Coverage Go Report Card

Golang package to return the elapsed time since a given time in a human-readable format.

Installation

$ go get -u github.com/rvflash/elapsed

Usage

t := time.Now().Add(-time.Hour)
fmt.Println(elapsed.Time(t))
// Output: 1 hour ago

t = time.Now().Add(-time.Hour * 24 * 3)
fmt.Println(elapsed.Time(t))
// Output:  3 days ago

t, _ = time.Parse("2006-02-01", "2049-08-19")
fmt.Println(elapsed.Time(t))
// Output: not yet

t = time.Now().Add(-time.Hour * 24 * 3)
fmt.Println(elapsed.LocalTime(t, "fr"))
// Output: il y a 3 jours

About

Golang package to return the elapsed time since a given time in a human readable format

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages