Skip to content

justincampbell/timeago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A port of Rails' time_ago_in_words to Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published