timex

package
v0.0.0-...-dcdaab2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

Time is a nullable time.Time. It supports SQL and JSON serialization. It will marshal to null if null.

func NewTime

func NewTime(t time.Time, valid bool) NullTime

NewTime creates a new Time.

func TimeFrom

func TimeFrom(t time.Time) NullTime

TimeFrom creates a new Time that will always be valid.

func TimeFromPtr

func TimeFromPtr(t *time.Time) NullTime

TimeFromPtr creates a new Time that will be null if t is nil.

func (NullTime) MarshalJSON

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

MarshalJSON implements json.Marshaler. It will encode null if this time is null.

func (NullTime) MarshalText

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

func (NullTime) Ptr

func (t NullTime) Ptr() *time.Time

Ptr returns a pointer to this Time's value, or a nil pointer if this Time is null.

func (*NullTime) Scan

func (t *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*NullTime) SetValid

func (t *NullTime) SetValid(v time.Time)

SetValid changes this Time's value and sets it to be non-null.

func (*NullTime) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler. It supports string, object (e.g. pq.NullTime and friends) and null input.

func (*NullTime) UnmarshalText

func (t *NullTime) UnmarshalText(text []byte) error

func (NullTime) Value

func (t NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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