Documentation ¶
Overview ¶
Package timeutil contains functions and types which aid in dealing with time
Index ¶
- type Timestamp
- func (t Timestamp) Float64() float64
- func (t Timestamp) GetBSON() (interface{}, error)
- func (t Timestamp) IsUnixZero() bool
- func (t Timestamp) MarshalJSON() ([]byte, error)
- func (t *Timestamp) SetBSON(raw bson.Raw) error
- func (t Timestamp) String() string
- func (t *Timestamp) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Timestamp ¶
Timestamp 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 TimestampFromFloat64 ¶
TimestampFromFloat64 returns a Timestamp 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 TimestampFromInt64 ¶
TimestampFromInt64 returns a Timestamp equal to the given int64, assuming it too is a unix timestamp
func TimestampFromString ¶
TimestampFromString attempts to parse the string as a float64, and then passes that into TimestampFromFloat64, returning the result
func TimestampNow ¶
func TimestampNow() Timestamp
TimestampNow is simply a wrapper around time.Now which returns a Timestamp.
func (Timestamp) 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 (Timestamp) MarshalJSON ¶
MarshalJSON returns the JSON representation of the Timestamp as an integer. It never returns an error
func (Timestamp) String ¶
String returns the string representation of the Timestamp, in the form of a floating point form of the time as a unix timestamp
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON takes a JSON integer and converts it into a Timestamp, or returns an error if this can't be done