Skip to content

Package that provides you with a method that describes the time between `time.Now()` and a given time

Notifications You must be signed in to change notification settings

victorjonsson/timeagoo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timeagoo

Build Status

This package provides you with a method that describes the time between time.Now() and a given time. It's an alternative package to justincampbell/timeago.

Dialogs describing the time difference

↓ Formatted date (eg. Mon Jan 2 2015)
↓ Yesterday hh:mm 
↓ Today hh:mm
↓ About %s minutes ago 
↓ About one minute ago 
↓ About %s seconds ago
↓ Recently
- Now
↑ Soon
↑ In about %s seconds
↑ In about one minute
↑ In about %s minutes
↑ Today hh:mm
↑ Tomorrow hh:mm
↑ Formatted date (eg. Mon Jan 2 2021)

API

func Format(time time.Time, dialogs timeagoo.language.Dialogs) string

package main

import (
    "github.com/victorjonsson/timeagoo"
    ...
)

...

func formatWhenIncidentOccurred(i Incident) {    
    return timeagoo.Format(i.time, timeagoo.EnglishDialogs{})
}

Multilingual support

The package comes with an English translation of all dialogs. You can use another language by implementing the Dialogs interface.

import "time"

type swedishDialogs struct {
}

func (swedishDialogs) Recently() string {
    return "Nyligen";
}
...

func FormatTimeagoo(t time.Time) string {
    return timeagoo.Format(t, swedishDialogs{})
}

About

Package that provides you with a method that describes the time between `time.Now()` and a given time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages