date

package
v0.0.0-...-82292ab Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatesDaysCompare

func DatesDaysCompare(high, low *Date) (int, error)

DatesDaysCompare returns an in

Types

type Date

type Date struct {
	// contains filtered or unexported fields
}

Date is a formatted time which contemplates days, months and years. Provides methods to parse from and to other formats and has Before, After... kind of operations. Unmarshals methods will work with "2006-01-02" formatted times.

Zero value Date is Jesus birthday: 0001-01-01

func DateFromDashYYYYMMDDFormat

func DateFromDashYYYYMMDDFormat(s string) (Date, error)

DateFromDashYYYYMMDDFormat builds a Date from a 2006-01-02 formatted time with no format validation. For format validations use the safe version (which is 100 times slower)

func DateFromDashYYYYMMDDFormatSafe

func DateFromDashYYYYMMDDFormatSafe(s string) (Date, error)

DateFromDashYYYYMMDDFormatSafe builds a Date from a 2006-01-02 formatted time validating the input This is 100 times slower than the unsafe version

func DateFromShortFormat

func DateFromShortFormat(s string) (Date, error)

DateFromShortFormat builds a Date from a 060102 formatted time

func DateFromSlashDDMMYYYYFormat

func DateFromSlashDDMMYYYYFormat(s string) (Date, error)

DateFromSlashDDMMYYYYFormat builds a Date from a 02/01/2006 formatted time

func DateFromTime

func DateFromTime(t time.Time) Date

DateFromTime builds a Date from a time.Time

func DateNow

func DateNow() Date

DateNow builds a Date from today

func (Date) After

func (d Date) After(u Date) bool

After evaluates if this date is a date after u

func (Date) AfterOrEqual

func (d Date) AfterOrEqual(u Date) bool

AfterOrEqual evaluates if this date is after or equals to u

func (Date) Before

func (d Date) Before(u Date) bool

Before evaluates if this date is a date before u

func (Date) BeforeOrEqual

func (d Date) BeforeOrEqual(u Date) bool

BeforeOrEqual evaluates if this date is before or equals to u

func (Date) Equal

func (d Date) Equal(u Date) bool

Equal evaluates if this date equals to u

func (Date) FormatToDashYYYYMMDD

func (d Date) FormatToDashYYYYMMDD() string

FormatToDashYYYYMMDD formats the Date to 2006-01-02 format

func (Date) FormatToShort

func (d Date) FormatToShort() string

FormatToShort formats the Date to 060102 format

func (Date) FormatToSlashDDMMYYYY

func (d Date) FormatToSlashDDMMYYYY() string

FormatToSlashDDMMYYYY formats a Date to 02/01/2006 format

func (Date) MarshalJSON

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

MarshalJSON supports json.Marshaler interface. Marshals to a "2006-01-02" formatted string

func (Date) Time

func (d Date) Time() (time.Time, error)

Time returns the 'time.Time' value corresponding to a Date. Note that hours of 'Time' will always be 0 since a Date only arranges from year to day

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshal interface. Expects a "2006-01-02" formatted string

Jump to

Keyboard shortcuts

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