date

package
v0.0.0-...-d88c8b5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package date provides time.Time derivatives that conform to the Swagger.io (https://swagger.io/) defined date formats: Date and DateTime. Both types may, in most cases, be used in lieu of time.Time types. And both convert to time.Time through a ToTime method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTime

func ParseTime(format string, t string) (d time.Time, err error)

ParseTime to parse Time string to specified format.

func UnixEpoch

func UnixEpoch() time.Time

UnixEpoch retreives the moment considered the Unix Epoch. I.e. The time represented by '0'

Types

type Date

type Date struct {
	time.Time
}

Date defines a type similar to time.Time but assumes a layout of RFC3339 full-date (i.e., 2006-01-02).

func ParseDate

func ParseDate(date string) (d Date, err error)

ParseDate create a new Date from the passed string.

func (Date) MarshalBinary

func (d Date) MarshalBinary() ([]byte, error)

MarshalBinary preserves the Date as a byte array conforming to RFC3339 full-date (i.e., 2006-01-02).

func (Date) MarshalJSON

func (d Date) MarshalJSON() (json []byte, err error)

MarshalJSON preserves the Date as a JSON string conforming to RFC3339 full-date (i.e., 2006-01-02).

func (Date) MarshalText

func (d Date) MarshalText() (text []byte, err error)

MarshalText preserves the Date as a byte array conforming to RFC3339 full-date (i.e., 2006-01-02).

func (Date) String

func (d Date) String() string

String returns the Date formatted as an RFC3339 full-date string (i.e., 2006-01-02).

func (Date) ToTime

func (d Date) ToTime() time.Time

ToTime returns a Date as a time.Time

func (*Date) UnmarshalBinary

func (d *Date) UnmarshalBinary(data []byte) error

UnmarshalBinary reconstitutes a Date saved as a byte array conforming to RFC3339 full-date (i.e., 2006-01-02).

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON reconstitutes the Date from a JSON string conforming to RFC3339 full-date (i.e., 2006-01-02).

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(data []byte) (err error)

UnmarshalText reconstitutes a Date saved as a byte array conforming to RFC3339 full-date (i.e., 2006-01-02).

type Time

type Time struct {
	time.Time
}

Time defines a type similar to time.Time but assumes a layout of RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

func (Time) MarshalBinary

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

MarshalBinary preserves the Time as a byte array conforming to RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

func (Time) MarshalJSON

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

MarshalJSON preserves the Time as a JSON string conforming to RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

func (Time) MarshalText

func (t Time) MarshalText() (text []byte, err error)

MarshalText preserves the Time as a byte array conforming to RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

func (Time) String

func (t Time) String() string

String returns the Time formatted as an RFC3339 date-time string (i.e., 2006-01-02T15:04:05Z).

func (Time) ToTime

func (t Time) ToTime() time.Time

ToTime returns a Time as a time.Time

func (*Time) UnmarshalBinary

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

UnmarshalBinary reconstitutes a Time saved as a byte array conforming to RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

func (*Time) UnmarshalJSON

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

UnmarshalJSON reconstitutes the Time from a JSON string conforming to RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(data []byte) (err error)

UnmarshalText reconstitutes a Time saved as a byte array conforming to RFC3339 date-time (i.e., 2006-01-02T15:04:05Z).

type TimeRFC1123

type TimeRFC1123 struct {
	time.Time
}

TimeRFC1123 defines a type similar to time.Time but assumes a layout of RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (TimeRFC1123) MarshalBinary

func (t TimeRFC1123) MarshalBinary() ([]byte, error)

MarshalBinary preserves the Time as a byte array conforming to RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (TimeRFC1123) MarshalJSON

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

MarshalJSON preserves the Time as a JSON string conforming to RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (TimeRFC1123) MarshalText

func (t TimeRFC1123) MarshalText() ([]byte, error)

MarshalText preserves the Time as a byte array conforming to RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (TimeRFC1123) String

func (t TimeRFC1123) String() string

String returns the Time formatted as an RFC1123 date-time string (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (TimeRFC1123) ToTime

func (t TimeRFC1123) ToTime() time.Time

ToTime returns a Time as a time.Time

func (*TimeRFC1123) UnmarshalBinary

func (t *TimeRFC1123) UnmarshalBinary(data []byte) error

UnmarshalBinary reconstitutes a Time saved as a byte array conforming to RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (*TimeRFC1123) UnmarshalJSON

func (t *TimeRFC1123) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON reconstitutes the Time from a JSON string conforming to RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

func (*TimeRFC1123) UnmarshalText

func (t *TimeRFC1123) UnmarshalText(data []byte) (err error)

UnmarshalText reconstitutes a Time saved as a byte array conforming to RFC1123 date-time (i.e., Mon, 02 Jan 2006 15:04:05 MST).

type UnixTime

type UnixTime time.Time

UnixTime marshals and unmarshals a time that is represented as the number of seconds (ignoring skip-seconds) since the Unix Epoch.

func NewUnixTimeFromDuration

func NewUnixTimeFromDuration(dur time.Duration) UnixTime

NewUnixTimeFromDuration creates a UnixTime as a duration of time since the UnixEpoch.

func NewUnixTimeFromNanoseconds

func NewUnixTimeFromNanoseconds(nanoseconds int64) UnixTime

NewUnixTimeFromNanoseconds creates a UnixTime as a number of nanoseconds from the UnixEpoch.

func NewUnixTimeFromSeconds

func NewUnixTimeFromSeconds(seconds float64) UnixTime

NewUnixTimeFromSeconds creates a UnixTime as a number of seconds from the UnixEpoch.

func (UnixTime) Duration

func (t UnixTime) Duration() time.Duration

Duration returns the time as a Duration since the UnixEpoch.

func (UnixTime) MarshalBinary

func (t UnixTime) MarshalBinary() ([]byte, error)

MarshalBinary converts a UnixTime into a binary.LittleEndian float64 of nanoseconds since the epoch.

func (UnixTime) MarshalJSON

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

MarshalJSON preserves the UnixTime as a JSON number conforming to Unix Timestamp requirements. (i.e. the number of seconds since midnight January 1st, 1970 not considering leap seconds.)

func (UnixTime) MarshalText

func (t UnixTime) MarshalText() ([]byte, error)

MarshalText stores the number of seconds since the Unix Epoch as a textual floating point number.

func (*UnixTime) UnmarshalBinary

func (t *UnixTime) UnmarshalBinary(raw []byte) error

UnmarshalBinary converts a from a binary.LittleEndian float64 of nanoseconds since the epoch into a UnixTime.

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(text []byte) error

UnmarshalJSON reconstitures a UnixTime saved as a JSON number of the number of seconds since midnight January 1st, 1970.

func (*UnixTime) UnmarshalText

func (t *UnixTime) UnmarshalText(raw []byte) error

UnmarshalText populates a UnixTime with a value stored textually as a floating point number of seconds since the Unix Epoch.

Jump to

Keyboard shortcuts

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