caarlos0 / timea.go

timea.go (did you see what I did there?) is a simple library to print given times in "time ago" manner.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

timea.go

Build Status Coverage Status

timea.go (did you see what I did there?) is a simple and 0-dependencies library to print given times in "time ago" manner.

Usage

Get it:

go get github.com/caarlos0/timea.go

Use it:

package main

import (
	"fmt"
	"time"

	timeago "github.com/caarlos0/timea.go"
)

func main() {
	fmt.Println(timeago.Of(time.Now().Add(-5 * time.Second))) // 5 seconds ago
	fmt.Println(timeago.Of(time.Now().Add(5 * time.Second))) // 5 seconds from now
}

You may also check the go docs for advanced usage, like custom precision and string templates.

Stargazers over time

Stargazers over time

About

timea.go (did you see what I did there?) is a simple library to print given times in "time ago" manner.

License:MIT License


Languages

Language:Go 96.9%Language:Makefile 3.1%