timeofday

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Min is the minimum TimeOfDay value (midnight).
	Min = TimeOfDay(0)

	// Time2400 is a special value to represent the 24:00 input time
	Time2400 = TimeOfDay(microsecondsPerDay)

	// Max is the maximum TimeOfDay value (1 second before midnight)
	Max = Time2400
)

Variables

This section is empty.

Functions

func Difference

func Difference(t1 TimeOfDay, t2 TimeOfDay) duration.Duration

Difference returns the interval between t1 and t2, which may be negative.

Types

type TimeOfDay

type TimeOfDay int64

TimeOfDay represents a time of day (no date), stored as microseconds since midnight.

func FromInt

func FromInt(i int64) TimeOfDay

FromInt constructs a TimeOfDay from an int64, representing microseconds since midnight. Inputs outside the range [0, microsecondsPerDay) are modded as appropriate.

func FromTime

func FromTime(t time.Time) TimeOfDay

FromTime constructs a TimeOfDay from a time.Time, ignoring the date and time zone.

func FromTimeAllow2400

func FromTimeAllow2400(t time.Time) TimeOfDay

FromTimeAllow2400 assumes 24:00 time is possible from the given input, otherwise falling back to FromTime. It assumes time.Time is represented as lib/pq or as unix time.

func New

func New(hour, min, sec, micro int) TimeOfDay

New creates a TimeOfDay representing the specified time.

func Random

func Random(rng *rand.Rand) TimeOfDay

Random generates a random TimeOfDay.

func (TimeOfDay) Add

Add adds a Duration to a TimeOfDay, wrapping into the next day if necessary.

func (TimeOfDay) Hour

func (t TimeOfDay) Hour() int

Hour returns the hour specified by t, in the range [0, 24].

func (TimeOfDay) Microsecond

func (t TimeOfDay) Microsecond() int

Microsecond returns the microsecond offset within the second specified by t, in the range [0, 999999].

func (TimeOfDay) Minute

func (t TimeOfDay) Minute() int

Minute returns the minute offset within the hour specified by t, in the range [0, 59].

func (TimeOfDay) Round

func (t TimeOfDay) Round(precision time.Duration) TimeOfDay

Round takes a TimeOfDay, and rounds it to the given precision.

func (TimeOfDay) Second

func (t TimeOfDay) Second() int

Second returns the second offset within the minute specified by t, in the range [0, 59].

func (TimeOfDay) String

func (t TimeOfDay) String() string

func (TimeOfDay) ToTime

func (t TimeOfDay) ToTime() time.Time

ToTime converts a TimeOfDay to a time.Time, using the Unix epoch as the date.

Jump to

Keyboard shortcuts

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