Package mtime extends the standard time package with extra functionality
Duration wraps time.Duration to implement marshaling and unmarshaling methods
MarshalJSON implements the json.Marshaler interface, marshaling the Duration as a json string via Duration's String method
MarshalText implements the text.Marshaler interface
UnmarshalJSON implements the json.Unmarshaler interface, unmarshaling the Duration as a JSON string and using the time.ParseDuration function on that
UnmarshalText implements the text.Unmarshaler interface
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
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.
NowTS is a wrapper around time.Now which returns a TS.
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
TSFromInt64 returns a TS equal to the given int64, assuming it too is a unix timestamp
TSFromString attempts to parse the string as a float64, and then passes that into TSFromFloat64, returning the result
Float64 returns the float representation of the timestamp in seconds.
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)
MarshalJSON returns the JSON representation of the TS as an integer. It never returns an error
String returns the string representation of the TS, in the form of a floating point form of the time as a unix timestamp
UnmarshalJSON takes a JSON integer and converts it into a TS, or returns an error if this can't be done