timestamp

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

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

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 New

func New(t time.Time) Timestamp

New creates a Timestamp from a time.Time value.

func (Timestamp) IsZero

func (ts Timestamp) IsZero() bool

IsZero reports whether the timestamp represents the zero time instant.

func (Timestamp) MarshalJSON

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

MarshalJSON implements json.Marshaler using RFC 3339 format.

func (Timestamp) MarshalText

func (ts Timestamp) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler using RFC 3339 format.

func (Timestamp) String

func (ts Timestamp) String() string

String returns the RFC 3339 representation of the timestamp.

func (Timestamp) Time

func (ts Timestamp) Time() time.Time

Time returns the underlying time.Time value.

func (*Timestamp) UnmarshalJSON

func (ts *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler expecting RFC 3339 format.

func (*Timestamp) UnmarshalText

func (ts *Timestamp) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler expecting RFC 3339 format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL