Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 978 Bytes

README.md

File metadata and controls

56 lines (43 loc) · 978 Bytes

timeago

Build Status GoDoc

A port of Rails' time_ago_in_words to Golang

Installation

go get github.com/justincampbell/timeago

Examples

Golang

package main

import (
	"fmt"
	"time"

	"github.com/justincampbell/timeago"
)

func main() {
	var d time.Duration

	d, _ = time.ParseDuration("25s")
	fmt.Println(timeago.FromDuration(d))
	d, _ = time.ParseDuration("55m")
	fmt.Println(timeago.FromDuration(d))
	d, _ = time.ParseDuration("72h")
	fmt.Println(timeago.FromDuration(d))
}
$ go run main.go
less than a minute
about 1 hour
3 days

Command-line

$ go get github.com/justincampbell/timeago/cmd/timeago
$ timeago 25s
less than a minute
$ timeago 55m
about 1 hour
$ timeago 72h
3 days