xtime

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 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 added in v0.24.0

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

Clock represents a clock that can retrieve current time.

type ClockMock added in v0.24.0

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

ClockMock is a clock mocking time with an internal counter.

func NewClockMock added in v0.24.0

func NewClockMock(originalTime time.Time) *ClockMock

NewClockMock returns a new ClockMock.

func (*ClockMock) Add added in v0.24.0

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

Add implements Clock.

func (ClockMock) Now added in v0.24.0

func (c ClockMock) Now() time.Time

Now implements Clock.

type ClockSystem added in v0.24.0

type ClockSystem struct{}

ClockSystem is a clock that retrieves system time.

func NewClockSystem added in v0.24.0

func NewClockSystem() ClockSystem

NewClockSystem returns a new ClockSystem.

func (ClockSystem) Add added in v0.24.0

func (ClockSystem) Add(_ time.Duration)

Add implements Clock.

func (ClockSystem) Now added in v0.24.0

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