xtime

package
v0.0.0-...-d298eb8 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatUnix

func FormatUnix(date time.Time) string

FormatUnix formats the time.Time to unix date string.

func FormatUnixInt

func FormatUnixInt(unix int64) string

FormatUnixInt formats the int timestamp to unix date string.

func NowAfter

func NowAfter(unix time.Duration) string

NowAfter returns a unix date string from now plus the duration.

func Seconds

func Seconds(seconds int64) time.Duration

Seconds creates a time.Duration based on the seconds parameter.

Types

type Clock

type Clock interface {
	Now() time.Time
	Add(duration time.Duration)
}

Clock represents a clock that can retrieve current time.

type ClockMock

type ClockMock struct {
	// contains filtered or unexported fields
}

ClockMock is a clock mocking time with an internal counter.

func NewClockMock

func NewClockMock(originalTime time.Time) *ClockMock

NewClockMock returns a new ClockMock.

func (*ClockMock) Add

func (c *ClockMock) Add(duration time.Duration)

Add implements Clock.

func (ClockMock) Now

func (c ClockMock) Now() time.Time

Now implements Clock.

type ClockSystem

type ClockSystem struct{}

ClockSystem is a clock that retrieves system time.

func NewClockSystem

func NewClockSystem() ClockSystem

NewClockSystem returns a new ClockSystem.

func (ClockSystem) Add

func (ClockSystem) Add(_ time.Duration)

Add implements Clock.

func (ClockSystem) Now

func (ClockSystem) Now() time.Time

Now implements Clock.

Jump to

Keyboard shortcuts

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