Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Timestamp ¶
Timestamp wraps a time.Time in a struct with a Valid bool so we can safely handle NULL values.
func NewFromPtr ¶
NewFromPtr wraps New to ensure that the provided *time.Time is not nil before deferencing it and creating a new Timestamp.
func Parse ¶
Parse wraps time.Parse. It'll return an error if the underlying call to time.Parse returns an error.
func ParseInLocation ¶
ParseInLocation wraps time.ParseInLocation. It'll return an error if the underlying call to time.ParseInLocation returns an error.
func (Timestamp) MarshalJSON ¶
MarshalJSON implements json.Marshaler. If the Timestamp is valid, it redirects to the time.Time's JSON marshaler; if it is not valid, it returns json.Marshal(nil).
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. If the incoming []byte == "null", it'll return a Timestamp with Valid set to false. Otherwise, it'll attempt to parse the time.Time and return a Timestamp with Valid set to true if it's able.