Package timeutil contains functions and types which aid in dealing with time



    This section is empty.


    This section is empty.


    This section is empty.


    type Timestamp

    type Timestamp struct {

      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

      func TimestampFromFloat64(ts float64) Timestamp

        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

        func TimestampFromInt64(ts int64) Timestamp

          TimestampFromInt64 returns a Timestamp equal to the given int64, assuming it too is a unix timestamp

          func TimestampFromString

          func TimestampFromString(ts string) (Timestamp, error)

            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) Float64

              func (t Timestamp) Float64() float64

                Float64 returns the float representation of the timestamp in seconds.

                func (Timestamp) GetBSON

                func (t Timestamp) GetBSON() (interface{}, error)

                  GetBSON implements the bson.Getter interface

                  func (Timestamp) IsUnixZero

                  func (t Timestamp) IsUnixZero() bool

                    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

                    func (t Timestamp) MarshalJSON() ([]byte, error)

                      MarshalJSON returns the JSON representation of the Timestamp as an integer. It never returns an error

                      func (*Timestamp) SetBSON

                      func (t *Timestamp) SetBSON(raw bson.Raw) error

                        SetBSON implements the bson.Setter interface

                        func (Timestamp) String

                        func (t Timestamp) String() 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

                          func (t *Timestamp) UnmarshalJSON(b []byte) error

                            UnmarshalJSON takes a JSON integer and converts it into a Timestamp, or returns an error if this can't be done