cockroach: Index | Files

package timeofday

import ""


Package Files



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

func Difference Uses

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

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

type TimeOfDay Uses

type TimeOfDay int64

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

func FromInt Uses

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 Uses

func FromTime(t time.Time) TimeOfDay

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

func FromTimeAllow2400 Uses

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 Uses

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

New creates a TimeOfDay representing the specified time.

func Random Uses

func Random(rng *rand.Rand) TimeOfDay

Random generates a random TimeOfDay.

func (TimeOfDay) Add Uses

func (t TimeOfDay) Add(d duration.Duration) TimeOfDay

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

func (TimeOfDay) Hour Uses

func (t TimeOfDay) Hour() int

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

func (TimeOfDay) Microsecond Uses

func (t TimeOfDay) Microsecond() int

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

func (TimeOfDay) Minute Uses

func (t TimeOfDay) Minute() int

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

func (TimeOfDay) Round Uses

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

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

func (TimeOfDay) Second Uses

func (t TimeOfDay) Second() int

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

func (TimeOfDay) String Uses

func (t TimeOfDay) String() string

func (TimeOfDay) ToTime Uses

func (t TimeOfDay) ToTime() time.Time

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

Package timeofday imports 6 packages (graph) and is imported by 43 packages. Updated 2020-06-20. Refresh now. Tools for package owners.