dates

package
v0.0.0-...-fad53ba Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultServerDateFormat is the Go layout for Date objects
	DefaultServerDateFormat = "2006-01-02"
	// DefaultServerDateTimeFormat is the Go layout for DateTime objects
	DefaultServerDateTimeFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	time.Time
}

Date type that JSON marshal and unmarshals as "YYYY-MM-DD"

func ParseDate

func ParseDate(layout, value string) (Date, error)

ParseDate returns a date from the given string value that is formatted with layout.

func Today

func Today() Date

Today returns the current date

func (Date) AddDate

func (d Date) AddDate(year, month, day int) Date

AddDate adds the given year, month or days to the current date

func (Date) Equal

func (d Date) Equal(other Date) bool

Equal reports whether d and other represent the same day

func (Date) Greater

func (d Date) Greater(other Date) bool

Greater returns true if d is strictly greater than other

func (Date) GreaterEqual

func (d Date) GreaterEqual(other Date) bool

GreaterEqual returns true if d is greater than or equal to other

func (Date) Lower

func (d Date) Lower(other Date) bool

Lower returns true if d is strictly lower than other

func (Date) LowerEqual

func (d Date) LowerEqual(other Date) bool

LowerEqual returns true if d is lower than or equal to other

func (Date) MarshalJSON

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

MarshalJSON for Date type

func (*Date) Scan

func (d *Date) Scan(src interface{}) error

Scan casts the database output to a Date

func (Date) String

func (d Date) String() string

String method for Date.

func (Date) Value

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

Value formats our Date for storing in database Especially handles empty Date.

type DateTime

type DateTime struct {
	time.Time
}

DateTime type that JSON marshals and unmarshals as "YYYY-MM-DD HH:MM:SS"

func Now

func Now() DateTime

Now returns the current date/time

func ParseDateTime

func ParseDateTime(layout, value string) (DateTime, error)

ParseDateTime returns a datetime from the given string value that is formatted with layout.

func (DateTime) Add

func (d DateTime) Add(duration time.Duration) DateTime

Add adds the given duration to this DateTime

func (DateTime) AddDate

func (d DateTime) AddDate(year, month, day int) DateTime

AddDate adds the given year, month or days to the current DateTime

func (DateTime) Equal

func (d DateTime) Equal(other DateTime) bool

Equal reports whether d and other represent the same time instant

func (DateTime) Greater

func (d DateTime) Greater(other DateTime) bool

Greater returns true if d is strictly greater than other

func (DateTime) GreaterEqual

func (d DateTime) GreaterEqual(other DateTime) bool

GreaterEqual returns true if d is greater than or equal to other

func (DateTime) Lower

func (d DateTime) Lower(other DateTime) bool

Lower returns true if d is strictly lower than other

func (DateTime) LowerEqual

func (d DateTime) LowerEqual(other DateTime) bool

LowerEqual returns true if d is lower than or equal to other

func (DateTime) MarshalJSON

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

MarshalJSON for DateTime type

func (*DateTime) Scan

func (d *DateTime) Scan(src interface{}) error

Scan casts the database output to a DateTime

func (DateTime) String

func (d DateTime) String() string

String method for DateTime.

func (DateTime) ToDate

func (d DateTime) ToDate() Date

ToDate returns the Date of this DateTime

func (DateTime) Value

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

Value formats our DateTime for storing in database Especially handles empty DateTime.

Jump to

Keyboard shortcuts

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