awstime

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package awstime provides helpers for emitting timestamps in the wire format expected by AWS JSON-protocol SDK deserializers.

The AWS "json" and "rest-json" protocols default to the unixTimestamp timestamp format, which serializes a point in time as a JSON number of seconds since the Unix epoch (with optional fractional milliseconds). The SDK deserializers reject RFC3339 strings for these shapes with an error of the form "expected Timestamp to be a JSON Number, got string instead".

Use Epoch to convert a time.Time into a value that json.Marshal renders as the correct numeric wire form.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Epoch

func Epoch(t time.Time) float64

Epoch converts t into seconds since the Unix epoch, preserving sub-second precision as a fractional component. The returned float64 is rendered by encoding/json as a JSON number, matching the unixTimestamp format used by the AWS json and rest-json protocols.

A zero time.Time returns 0, matching AWS behavior of omitting unset timestamps (callers that must omit the field entirely should guard on t.IsZero() before adding it to the response).

Types

This section is empty.

Jump to

Keyboard shortcuts

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