https://github.com/rvflash/elapsed
Golang package to return the elapsed time since a given time in a human readable format
https://github.com/rvflash/elapsed
golang time
Last synced: 16 days ago
JSON representation
Golang package to return the elapsed time since a given time in a human readable format
- Host: GitHub
- URL: https://github.com/rvflash/elapsed
- Owner: rvflash
- License: mit
- Created: 2017-09-24T12:42:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-08T16:01:22.000Z (8 months ago)
- Last Synced: 2025-05-07T03:10:01.754Z (16 days ago)
- Topics: golang, time
- Language: Go
- Size: 21.5 KB
- Stars: 35
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elapsed time
[](https://godoc.org/github.com/rvflash/elapsed)
[](https://github.com/rvflash/elapsed/actions?workflow=build)
[](https://codecov.io/gh/rvflash/elapsed)
[](https://goreportcard.com/report/github.com/rvflash/elapsed)Golang package to return the elapsed time since a given time in a human-readable format.
### Installation
```bash
$ go get -u github.com/rvflash/elapsed
```### Usage
```go
t := time.Now().Add(-time.Hour)
fmt.Println(elapsed.Time(t))
// Output: 1 hour agot = time.Now().Add(-time.Hour * 24 * 3)
fmt.Println(elapsed.Time(t))
// Output: 3 days agot, _ = time.Parse("2006-02-01", "2049-08-19")
fmt.Println(elapsed.Time(t))
// Output: not yett = time.Now().Add(-time.Hour * 24 * 3)
fmt.Println(elapsed.LocalTime(t, "fr"))
// Output: il y a 3 jours
```