nulldate

package
v0.0.0-...-a90befe Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 7 Imported by: 0

README

nulldate

Usage

type NullDate
type NullDate struct {
	Date  date.Date
	Valid bool
}

NullDate is the nullable type for Date only. Support UTC timezone only Null if valid is true

func MustParse
func MustParse(s string) NullDate

MustParse creates a new Date from the RFC3339 Date - "2006-01-02" Panic if wrong format

func New
func New(t time.Time, valid bool) NullDate

New creates a new Date

func NewDate
func NewDate(year int, month time.Month, day int) NullDate

NewDate from year, month and day

func NewFrom
func NewFrom(t time.Time) NullDate

NewFrom creates a new Date that will be valid

func NewFromPtr
func NewFromPtr(t *time.Time) NullDate

NewFromPtr creates a Date that be null if t is nil

func NewFromStr
func NewFromStr(s string) (NullDate, error)

NewFromStr creates a new Date from the RFC3339 Date - "2006-01-02"

func NewZero
func NewZero() NullDate

NewZero creates the new zero (null) Date

func (NullDate) GormDataType
func (d NullDate) GormDataType() string

GormDataType gorm common data type

func (NullDate) IsZero
func (d NullDate) IsZero() bool

IsZero returns true for invalid Date's, for omitempty support

func (NullDate) MarshalJSON
func (d NullDate) MarshalJSON() ([]byte, error)

MarshalJSON marshal to the JSON

func (*NullDate) Scan
func (d *NullDate) Scan(value interface{}) (err error)

Scan implements the Scanner interface

func (*NullDate) SetValid
func (d *NullDate) SetValid(t time.Time)

SetValid changes this Date's value and also sets it to be non-null

func (NullDate) String
func (d NullDate) String() string

Strong converts the Date to string as RFC3339 format It will be empty string if the Date is null

func (NullDate) ToTime
func (d NullDate) ToTime() time.Time

ToTime returns a time.Time to this Date's value

func (*NullDate) UnmarshalJSON
func (d *NullDate) UnmarshalJSON(bs []byte) error

UnmarshalJSON to parse the JSON

func (NullDate) Value
func (d NullDate) Value() (driver.Value, error)

Value implements the driver Valuer interface

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NullDate

type NullDate struct {
	Date  date.Date
	Valid bool
}

NullDate is the nullable type for Date only. Support UTC timezone only Null if valid is true

func MustParse

func MustParse(s string) NullDate

MustParse creates a new Date from the RFC3339 Date - "2006-01-02" Panic if wrong format

func New

func New(t time.Time, valid bool) NullDate

New creates a new Date

func NewDate

func NewDate(year int, month time.Month, day int) NullDate

NewDate from year, month and day

func NewFrom

func NewFrom(t time.Time) NullDate

NewFrom creates a new Date that will be valid

func NewFromPtr

func NewFromPtr(t *time.Time) NullDate

NewFromPtr creates a Date that be null if t is nil

func NewFromStr

func NewFromStr(s string) (NullDate, error)

NewFromStr creates a new Date from the RFC3339 Date - "2006-01-02"

func NewZero

func NewZero() NullDate

NewZero creates the new zero (null) Date

func (NullDate) GormDataType

func (d NullDate) GormDataType() string

GormDataType gorm common data type

func (NullDate) IsZero

func (d NullDate) IsZero() bool

IsZero returns true for invalid Date's, for omitempty support

func (NullDate) MarshalJSON

func (d NullDate) MarshalJSON() ([]byte, error)

MarshalJSON marshal to the JSON

func (*NullDate) Scan

func (d *NullDate) Scan(value interface{}) (err error)

Scan implements the Scanner interface

func (*NullDate) SetValid

func (d *NullDate) SetValid(t time.Time)

SetValid changes this Date's value and also sets it to be non-null

func (NullDate) String

func (d NullDate) String() string

Strong converts the Date to string as RFC3339 format It will be empty string if the Date is null

func (NullDate) ToTime

func (d NullDate) ToTime() time.Time

ToTime returns a time.Time to this Date's value

func (*NullDate) UnmarshalJSON

func (d *NullDate) UnmarshalJSON(bs []byte) error

UnmarshalJSON to parse the JSON

func (NullDate) Value

func (d NullDate) 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