Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.