timeutil

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package timeutil includes helpers for working with timestamps.

Index

Constants

View Source
const (
	SecondsPerHour = 60 * 60
	SecondsPerDay  = 60 * 60 * 24
)

SecondsPerXYZ

Variables

This section is empty.

Functions

func DiffHours

func DiffHours(t1, t2 time.Time) (hours int)

DiffHours returns the difference in hours between two times.

func FromMilliseconds

func FromMilliseconds(millis float64) time.Duration

FromMilliseconds returns a duration from a given float64 millis value.

func Max

func Max(times ...time.Time) time.Time

Max returns the earliest (min) time in a list of times.

func Milliseconds

func Milliseconds(d time.Duration) float64

Milliseconds returns a duration as milliseconds.

func Min

func Min(times ...time.Time) (min time.Time)

Min returns the earliest (min) time in a list of times.

func MinMax

func MinMax(times ...time.Time) (min time.Time, max time.Time)

MinMax returns the minimum and maximum times in a given range.

func ToFloat64

func ToFloat64(t time.Time) float64

ToFloat64 returns a float64 representation of a time.

Types

type Ascending

type Ascending []time.Time

Ascending sorts a given list of times ascending, or min to max.

func (Ascending) Len

func (a Ascending) Len() int

Len implements sort.Sorter

func (Ascending) Less

func (a Ascending) Less(i, j int) bool

Less implements sort.Sorter

func (Ascending) Swap

func (a Ascending) Swap(i, j int)

Swap implements sort.Sorter

type Descending

type Descending []time.Time

Descending sorts a given list of times ascending, or min to max.

func (Descending) Len

func (d Descending) Len() int

Len implements sort.Sorter

func (Descending) Less

func (d Descending) Less(i, j int) bool

Less implements sort.Sorter

func (Descending) Swap

func (d Descending) Swap(i, j int)

Swap implements sort.Sorter

Jump to

Keyboard shortcuts

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