lystype

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 3 Imported by: 0

README

lystype

Date/time types used in lys and lyspg.

The types here have 2 features not present in the equivalent pgx types:

  • they have default zero values
  • they marshal to JSON in an easily readable format

Documentation

Overview

Package lystype contains date/time types used in lys and lyspg.

Index

Constants

View Source
const (
	// TimeFormat is the format into which Time values are marshalled
	TimeFormat   string = "15:04"    // use when marshalling to json
	TimeFormatDb string = "15:04:05" // use when inserting into db
)
View Source
const (
	// DateFormat is the format into which Date values are marshalled
	DateFormat string = "2006-01-02"
)
View Source
const (
	// DatetimeFormat is the format into which Datetime values are marshalled
	DatetimeFormat string = "2006-01-02 15:04:05-07"
)

Variables

This section is empty.

Functions

func ToPtr

func ToPtr[T any](a T) *T

Types

type Date

type Date time.Time

Date is an implementation of time.Time which represents dates exchanged via json

func (Date) Format

func (t Date) Format(layout string) string

Format is a wrapper for the same function on the underlying time.Time variable

func (Date) IsZero

func (t Date) IsZero() bool

IsZero is a wrapper for the same function on the underlying time.Time variable

func (Date) MarshalJSON

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

MarshalJSON converts the receiver to json

func (*Date) Scan

func (t *Date) Scan(src any) error

Scan implements the database/sql Scanner interface lib/pq doesn't need this, but pgx does

func (*Date) UnmarshalJSON

func (t *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON converts the supplied json to a Date and writes the result to the receiver

type Datetime

type Datetime time.Time

Datetime is an implementation of time.Time which represents datetimes exchanged via json

func (Datetime) Format

func (t Datetime) Format(layout string) string

Format is a wrapper for the same function on the underlying time.Time variable

func (Datetime) IsZero

func (t Datetime) IsZero() bool

IsZero is a wrapper for the same function on the underlying time.Time variable

func (Datetime) MarshalJSON

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

MarshalJSON converts the receiver to json

func (*Datetime) Scan

func (t *Datetime) Scan(src any) error

Scan implements the database/sql Scanner interface lib/pq doesn't need this, but pgx does

func (*Datetime) UnmarshalJSON

func (t *Datetime) UnmarshalJSON(b []byte) error

UnmarshalJSON converts the supplied json to a Datetime and writes the result to the receiver

type Time

type Time time.Time

Time is an implementation of time.Time which represents times exchanged via json

func (Time) Format

func (t Time) Format(layout string) string

Format is a wrapper for the same function on the underlying time.Time variable

func (Time) IsZero

func (t Time) IsZero() bool

IsZero is a wrapper for the same function on the underlying time.Time variable

func (Time) MarshalJSON

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

MarshalJSON converts the receiver to json

func (*Time) Scan

func (t *Time) Scan(src any) error

Scan implements the database/sql Scanner interface lib/pq doesn't need this, but pgx does

func (*Time) UnmarshalJSON

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

UnmarshalJSON converts the supplied json to a Time and writes the result to the receiver

Jump to

Keyboard shortcuts

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