Documentation ¶
Overview ¶
Package mtime extends the standard time package with extra functionality
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
Duration wraps time.Duration to implement marshaling and unmarshaling methods
func (Duration) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface, marshaling the Duration as a json string via Duration's String method
func (Duration) MarshalText ¶
MarshalText implements the text.Marshaler interface
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface, unmarshaling the Duration as a JSON string and using the time.ParseDuration function on that
func (*Duration) UnmarshalText ¶
UnmarshalText implements the text.Unmarshaler interface
type TS ¶
TS is a wrapper around time.Time which adds methods to marshal and unmarshal the value as a unix timestamp instead of a formatted string
func NewTS ¶
NewTS returns a new TS instance wrapping the given time.Time, which will possibly be truncated a certain amount to account for floating point precision.
func TSFromFloat64 ¶
TSFromFloat64 returns a TS equal to the given float64, assuming it too is a unix timestamp. The float64 is interpreted as number of seconds, with everything after the decimal indicating milliseconds, microseconds, and nanoseconds
func TSFromInt64 ¶
TSFromInt64 returns a TS equal to the given int64, assuming it too is a unix timestamp
func TSFromString ¶
TSFromString attempts to parse the string as a float64, and then passes that into TSFromFloat64, returning the result
func (TS) IsUnixZero ¶
IsUnixZero returns true if the timestamp is equal to the unix zero timestamp, representing 1/1/1970. This is different than checking if the timestamp is the empty value (which should be done with IsZero)
func (TS) MarshalJSON ¶
MarshalJSON returns the JSON representation of the TS as an integer. It never returns an error
func (TS) String ¶
String returns the string representation of the TS, in the form of a floating point form of the time as a unix timestamp
func (*TS) UnmarshalJSON ¶
UnmarshalJSON takes a JSON integer and converts it into a TS, or returns an error if this can't be done