timeago

package module
v0.0.0-...-e9969cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2016 License: MIT Imports: 4 Imported by: 16

README

timeago

Build Status Coverage Status

TimeAgo is a library used to calculate how much time has been passed between two dates, this library is mainly based on time type of go.

Example

import (
  "fmt"
  "time"
  timeago "github.com/ararog/timeago"
)

d, _ := time.ParseDuration("-3h")
start := time.Now()
end := time.Now().Add(d)
got, _ := timeago.TimeAgoWithTime(start, end)
fmt.Printf("Output: %s\n", got)

Documentation

Overview

Package time provides a set of functions to return how much time has been passed between two dates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimeAgoFromNowWithString

func TimeAgoFromNowWithString(layout, end string) (string, error)

TimeAgoFromNowWithTime takes a specific layout as time format to parse the time string on end paramter to return how much time has been passed between the current time and the string representation of the time provided by user.

func TimeAgoFromNowWithTime

func TimeAgoFromNowWithTime(end time.Time) (string, error)

TimeAgoFromNowWithTime takes a specific end Time value and the current Time to return how much has been passed between them.

func TimeAgoWithString

func TimeAgoWithString(layout, start, end string) (string, error)

TimeAgoWithString takes a specific layout as time format to parse the time string on start/end parameter to return how much time has been passed between them.

func TimeAgoWithTime

func TimeAgoWithTime(start, end time.Time) (string, error)

TimeAgoWithTime takes a specific start/end Time values and calculate how much time has been passed between them.

Types

type DateAgoValues

type DateAgoValues int
const (
	SecondsAgo DateAgoValues = iota
	MinutesAgo
	HoursAgo
	DaysAgo
	WeeksAgo
	MonthsAgo
	YearsAgo
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL