timeutil

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Future

func Future(duration time.Duration) time.Time

Future provides a time.Time duration into the future from now

func NullTimeToTimestamp

func NullTimeToTimestamp(nt mysql.NullTime) *timestamp.Timestamp

NullTimeToTimestamp returns a protobuf Timestamp from a mysql.NullTime

func Past

func Past(duration time.Duration) time.Time

Past provides a time.Time duration into the past from now

func TimeToNullTime

func TimeToNullTime(t time.Time) mysql.NullTime

TimeToNullTime coverts a Time into a NullTime

func TimeToTimestamp

func TimeToTimestamp(t time.Time) *timestamp.Timestamp

TimeToTimestamp returns a protobuf Timestamp from a Time object

func TimestampToNilOrTime

func TimestampToNilOrTime(ts *timestamp.Timestamp) *time.Time

TimestampToNilOrTime returns a time.Time or nil (for JSON) from a protobuf Timestamp

func TimestampToNullTime

func TimestampToNullTime(ts *timestamp.Timestamp) mysql.NullTime

TimestampToNullTime returns a mysql.NullTime from a protobuf Timestamp

func TimestampToTime

func TimestampToTime(ts *timestamp.Timestamp) time.Time

TimestampToTime returns a Time object from a protobuf Timestamp

Types

type RunStop

type RunStop interface {
	Run()
	Running() bool
	Stop()
}

RunStop exposes a functions for running, stopping, and querying status of presumably a background job.

func RunEvery

func RunEvery(f func(), wait time.Duration) RunStop

RunEvery wait duration. Use returned channel to stop.

type Ticker

type Ticker interface {
	// Start this ticker sending time on it's channel.
	Start() Ticker
	// Reset this ticker by creating a new channel and sending time on it.
	Reset()
	// Stop this ticker and release underlying resources.
	Stop()
	// SetPeriod of this ticker to the passed duration. The ticker must be restarted
	// after this change.
	SetPeriod(period time.Duration)
	// Channel that is used to send the 'ticks'
	Channel() <-chan time.Time
}

Ticker sends the time, after a period, on it's channel once started.

func NewTicker

func NewTicker(period time.Duration) Ticker

NewTicker returns a new Ticker containing a channel that will send the time with a period specified by the duration argument once Started. It adjusts the intervals or drops ticks to make up for slow receivers. The duration d must be greater than zero; if not, NewTicker will panic. Stop the ticker to release associated resources.

Jump to

Keyboard shortcuts

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