timef

package
v0.0.0-...-66c7a0d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

time format, time calculation, all time related things.

Index

Constants

View Source
const (
	DefaultNumberOfTimeUnits = 2
	MaxNumberOfTimeUnits     = 6
)

Variables

This section is empty.

Functions

func Diff

func Diff(a, b time.Time) (year, month, day, hour, min, sec int)

Diff returns the specific interval between two times Reference: https://stackoverflow.com/a/36531443

func DiffPrettyAllUnits

func DiffPrettyAllUnits(a, b time.Time) string

DiffPrettyAllUnits returns an interval between two times in a pretty format (single string) for all units, it uses the func DiffPrettyNUnits() with the MaxNumberOfTimeUnits const

func DiffPrettyNUnits

func DiffPrettyNUnits(a, b time.Time, numberOfUnits int) string

DiffPrettyNUnits returns an interval between two times in a pretty format (single string) depending on the provided number of units this function will return 1-All time unit(s),

e.g. when the interval has only days, hours, minutes and seconds:

  • (all units) 1 day, 7 hours, 40 minutes, 49 seconds
  • (3 units) 1 day, 7 hours,
  • (1 units) 1 day

e.g. when the interval has all units:

  • (all units) 1 year, 4 months, 1 day, 7 hours, 40 minutes, 49 seconds
  • (3 units) 1 year, 4 months, 1 day
  • (1 units) 1 year

func IntervalUntilNow

func IntervalUntilNow(t time.Time) string

IntervalUntilNow is the short form of 'DiffPrettyNUnits(timeA, now, defaultUnits)'

Types

This section is empty.

Jump to

Keyboard shortcuts

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