pgtime

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package pgtime provides a wrapper around the raw Postgres 'timestamp with time zone' that comes back from the API, providing JSON marshalling and unmarshalling

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PgTime

type PgTime struct {
	time.Time
}

PgTime can be used just like time.Time. When used in JSON unmarshalling, it parses the field into a standard time.Time structure. If the value in the JSON is null, this is set to the zero value of time.Time{}. When marshalled, the JSON value will be an epoch integer timestamp, set in the UTC timezone

func (*PgTime) AsUTC

func (p *PgTime) AsUTC() time.Time

AsUTC returns a time.Time in UTC timezone

func (*PgTime) MarshalJSON

func (p *PgTime) MarshalJSON() (b []byte, err error)

MarshalJSON translates the time struct into a string, specifically an epoch integer timestamp set in the UTC timezone. If the time is a zero value, the strign "null" is used instead

func (*PgTime) UnmarshalJSON

func (p *PgTime) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON parses the incoming string value into something useful. In the case of null or error, the zero value of time.Time{} is used

Jump to

Keyboard shortcuts

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