Documentation
¶
Overview ¶
Package timestamp provides a UTC-normalized timestamp type with RFC 3339 serialization.
Use this package when you need consistent time representation across systems. All timestamps are automatically converted to UTC, eliminating timezone ambiguity in serialized data. The type implements JSON and text marshaling interfaces for seamless integration with APIs and configuration files.
Index ¶
- type Timestamp
- func (ts Timestamp) IsZero() bool
- func (ts Timestamp) MarshalJSON() ([]byte, error)
- func (ts Timestamp) MarshalText() ([]byte, error)
- func (ts Timestamp) String() string
- func (ts Timestamp) Time() time.Time
- func (ts *Timestamp) UnmarshalJSON(data []byte) error
- func (ts *Timestamp) UnmarshalText(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Timestamp ¶
type Timestamp struct {
// contains filtered or unexported fields
}
Timestamp represents a point in time stored as an RFC 3339 string for universal compatibility. It is implemented as a struct with a private field rather than a type alias (type Timestamp time.Time) to enforce the invariant that all timestamps are normalized to UTC. This prevents callers from bypassing the constructor and creating timestamps in non-UTC timezones.
func (Timestamp) MarshalJSON ¶
MarshalJSON implements json.Marshaler using RFC 3339 format.
func (Timestamp) MarshalText ¶
MarshalText implements encoding.TextMarshaler using RFC 3339 format.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler expecting RFC 3339 format.