timeutil

package module
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 5 Imported by: 1

README

timeutil

Go Reference test Go Report Card

Installation

go get github.com/m0t0k1ch1-go/timeutil/v3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() Timestamp
}

Clock is an interface for getting the current Timestamp.

func NewClock

func NewClock() Clock

NewClock returns a new Clock.

type MockClock

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

MockClock is a mock implementation of Clock.

func NewMockClock

func NewMockClock(ts Timestamp) *MockClock

NewMockClock returns a new MockClock.

func (*MockClock) Now

func (clk *MockClock) Now() Timestamp

Now returns the mock Timestamp.

func (*MockClock) Set

func (clk *MockClock) Set(ts Timestamp)

Set sets the mock Timestamp.

type Timestamp

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

Timestamp is a wrapper for time.Time.

func Now

func Now() Timestamp

Now returns the current Timestamp.

func TimeToTimestamp

func TimeToTimestamp(t time.Time) Timestamp

TimeToTimestamp return the Timestamp that wraps the given time.Time.

func (Timestamp) MarshalJSON

func (ts Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Timestamp) Scan

func (ts *Timestamp) Scan(src any) error

Scan implements the sql.Scanner interface.

func (Timestamp) String

func (ts Timestamp) String() string

String implements the fmt.Stringer interface.

func (Timestamp) Time

func (ts Timestamp) Time() time.Time

Time returns the wrapped time.Time.

func (*Timestamp) UnmarshalJSON

func (ts *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (Timestamp) Value

func (ts Timestamp) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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