Categorygithub.com/caarlos0/timea.go
modulepackage
1.2.0
Repository: https://github.com/caarlos0/timea.go.git
Documentation: pkg.go.dev

# README

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

# Functions

Of returns the string representation of the given time with the given options.

# Constants

DayPrecision is the day precision.
HourPrecision is the hour precision.
MinutePrecision is the minute precision.
MonthPrecision is the month precision.
SecondPrecision is the second precision.
YearPrecision is the year precision.

# Variables

DefaultFormat is the default format of the string returned by the library.

# Structs

Format is the format of the string returned by the library.
Options define the options of the library.

# Type aliases

Precision define the minimum amount of time to be considered.