timetools

package
Version: v0.7.0 Latest Latest
Warning

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

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

README

timetools

Go library with various time utilities used at Mailgun.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FreezedTime

type FreezedTime struct {
	CurrentTime time.Time
}

FreezedTime is manually controlled time for use in tests.

func (*FreezedTime) Sleep

func (t *FreezedTime) Sleep(d time.Duration)

func (*FreezedTime) UtcNow

func (t *FreezedTime) UtcNow() time.Time

type RFC2822Time

type RFC2822Time time.Time

We use RFC2822 format for timestamps everywhere ('Thu, 13 Oct 2011 18:02:00 GMT'), but by default Go's JSON package uses another format when decoding/encoding timestamps. That's why we declare our own timestamp type and implement its marshal/unmarshal methods so JSON package decodes/encodes it properly.

func NewRFC2822Time

func NewRFC2822Time(timestamp int64) RFC2822Time

func (RFC2822Time) IsZero

func (t RFC2822Time) IsZero() bool

func (RFC2822Time) MarshalJSON

func (t RFC2822Time) MarshalJSON() ([]byte, error)

func (RFC2822Time) String

func (t RFC2822Time) String() string

func (RFC2822Time) Unix

func (t RFC2822Time) Unix() int64

func (*RFC2822Time) UnmarshalJSON

func (t *RFC2822Time) UnmarshalJSON(s []byte) error

type RealTime

type RealTime struct {
}

RealTime is a real clock time, used in production.

func (*RealTime) Sleep

func (*RealTime) Sleep(d time.Duration)

func (*RealTime) UtcNow

func (*RealTime) UtcNow() time.Time

type TimeProvider

type TimeProvider interface {
	UtcNow() time.Time
	Sleep(time.Duration)
}

TimeProvider is an interface we use to mock time in tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL