datetime

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: BSD-3-Clause Imports: 2 Imported by: 61

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DateTime

type DateTime time.Time

DateTime is an alias for time.Time which implements serialization matching the Conjure wire specification at https://github.com/palantir/conjure/blob/master/docs/spec/wire.md

Note that the wire specification states only "In accordance with ISO 8601." The Go implementation will marshal all output for this type using the time.RFC3339Nano format. The Go implementation will unmarshal all representations that adhere to the time.RFC3339Nano format and also supports unmarshalling any of the following ISO-8601 formats:

  • uuuu-MM-dd'T'HH:mmXXXXX
  • uuuu-MM-dd'T'HH:mm:ssXXXXX
  • uuuu-MM-dd'T'HH:mm:ss.SSSXXXXX
  • uuuu-MM-dd'T'HH:mm:ss.SSSSSSXXXXX
  • uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX

The above formats are specifically supported because they are the formats produced by Java's OffsetDateTime type's ToString method (https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html#toString--).

func ParseDateTime

func ParseDateTime(s string) (DateTime, error)

ParseDateTime parses a DateTime from a string. Supports all strings that match the time.RFC3339Nano format as well as ISO 8601 formats produced by Java's OffsetDateTime type. If the provided string contains an open bracket ('['), only parses the input before the first occurrence of the open bracket (this is to support inputs that end with an optional zone identifier enclosed in square brackets: for example, "2017-01-02T04:04:05.000000000+01:00[Europe/Berlin]").

func (DateTime) MarshalText

func (d DateTime) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler (used by encoding/json and others).

func (DateTime) String

func (d DateTime) String() string

func (*DateTime) UnmarshalText

func (d *DateTime) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler (used by encoding/json and others).

Jump to

Keyboard shortcuts

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