ticks

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const ShortTimeFormat string = "15:04:05.999"

ShortTimeFormat is the standard time.Time format used for showing just the timestamp portion of a Ticks value.

View Source
const TimeFormat string = "2006-01-02 15:04:05.999999999"

TimeFormat is the standard time.Time format used for a Ticks value.

Variables

This section is empty.

Functions

func IsLeapSecond

func IsLeapSecond(ticks Ticks) bool

IsLeapSecond determines if the deserialized Ticks value represents a leap second, i.e., second 60.

func ToTime

func ToTime(ticks Ticks) time.Time

ToTime converts a Ticks value to standard Go Time value.

Types

type Ticks

type Ticks uint64

Ticks is a 64-bit integer used to designate time in STTP. The value represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 UTC, Gregorian calendar. A single tick represents one hundred nanoseconds, or one ten-millionth of a second. There are 10,000 ticks in a millisecond and 10 million ticks in a second. Only bits 01 to 62 (0x3FFFFFFFFFFFFFFF) are used to represent the timestamp value. Bit 64 (0x8000000000000000) is used to denote leap second, i.e., second 60, where actual second value would remain at 59. Bit 63 is reserved and unset.

const LeapSecondFlag Ticks = 1 << 63

LeapSecondFlag is the flag (64th bit) that marks a Ticks value as a leap second, i.e., second 60 (one beyond normal second 59).

const Max Ticks = 3155378975999999999

Max is the maximum value for Ticks. It represents UTC time 12/31/1999 11:59:59.999.

const Min Ticks = 0

Min is the minimum value for Ticks. It represents UTC time 01/01/0001 00:00:00.000.

const PerDay Ticks = 24 * PerHour

PerDay is the number of Ticks that occur in a day.

const PerHour Ticks = 60 * PerMinute

PerHour is the number of Ticks that occur in an hour.

const PerMicrosecond Ticks = PerSecond / 1000000

PerMicrosecond is the number of Ticks that occur in a microsecond.

const PerMillisecond Ticks = PerSecond / 1000

PerMillisecond is the number of Ticks that occur in a millisecond.

const PerMinute Ticks = 60 * PerSecond

PerMinute is the number of Ticks that occur in a minute.

const PerSecond Ticks = 10000000

PerSecond is the number of Ticks that occur in a second.

const ReservedUTCFlag Ticks = 1 << 62

ReservedUTCFlag is the reserved flag (63rd bit) that should be unset when serializing and deserializing Ticks.

const UnixBaseOffset Ticks = 621355968000000000

UnixBaseOffset is the Ticks representation of the Unix epoch timestamp starting at January 1, 1970.

const ValueMask Ticks = ^LeapSecondFlag & ^ReservedUTCFlag

ValueMask defines all bits (bits 1 to 62) that make up the value portion of a Ticks that represent time.

func FromTime

func FromTime(time time.Time) Ticks

FromTime converts a standard Go Time value to a Ticks value.

func SetLeapSecond

func SetLeapSecond(ticks Ticks) Ticks

SetLeapSecond flags a Ticks value to represent a leap second, i.e., second 60, before wire serialization.

func UtcNow

func UtcNow() Ticks

UtcNow gets the current time in UTC as a Ticks value.

func (Ticks) IsLeapSecond added in v0.5.0

func (t Ticks) IsLeapSecond() bool

IsLeapSecond determines if the deserialized Ticks value represents a leap second, i.e., second 60.

func (Ticks) SetLeapSecond added in v0.5.0

func (t Ticks) SetLeapSecond() Ticks

SetLeapSecond flags a Ticks value to represent a leap second, i.e., second 60, before wire serialization.

func (Ticks) ShortTime added in v0.5.0

func (t Ticks) ShortTime() string

ShortTime returns the short time string form of a Ticks value.

func (Ticks) String added in v0.5.0

func (t Ticks) String() string

String returns the string form of a Ticks value, i.e., a standard date/time value. See TimeFormat.

func (Ticks) ToTime added in v0.5.0

func (t Ticks) ToTime() time.Time

ToTime converts a Ticks value to standard Go Time value.

Jump to

Keyboard shortcuts

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