iso8601ms

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 1 Imported by: 2

README

iso8601ms

Package iso8601 is a simple Go package for encoding time.Time in JSON in ISO 8601 format with millisecond precision, with the converted UTC timezone.

Standard iso8601 with millisecond precision: https://docs.jsonata.org/date-time

t := iso8601ms.Time(time.Now())
jsonBytes, _ := json.Marshal(t)
fmt.Println(string(jsonBytes))

// "2021-03-11T01:14:28.625Z"
// Same as JavaScript's Date().toISOString()

Documentation

Overview

Package iso8601ms package encodes and decodes time.Time in JSON in ISO 8601 with millisecond precision format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Time

type Time time.Time

Time is a iso8601ms struct

func (Time) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

Jump to

Keyboard shortcuts

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