dateutil

package
v0.0.0-...-78411ff Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dateutil provides tools and types for handling date and time information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginningOfMonth deprecated

func BeginningOfMonth(t time.Time) time.Time

BeginningOfMonth returns the date of the first day of the month

Deprecated: Use a toolkit like github.com/jinzhu/now instead

func BeginningOfYear deprecated

func BeginningOfYear(t time.Time) time.Time

BeginningOfYear returns the date of the first day of the year

Deprecated: Use a toolkit like github.com/jinzhu/now instead

func EndOfMonth deprecated

func EndOfMonth(t time.Time) time.Time

EndOfMonth returns the date of the last day of the month

Deprecated: Use a toolkit like github.com/jinzhu/now instead

func EndOfYear deprecated

func EndOfYear(t time.Time) time.Time

EndOfYear returns the date of the first day of the year

Deprecated: Use a toolkit like github.com/jinzhu/now instead

Types

type Date

type Date struct {
	civil.Date
}

Date is a native date in YYYY-MM-DD format

func DateOf

func DateOf(t time.Time) Date

DateOf constructs a Date type from given time

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate returns a Date type parsed from a string

func (Date) After

func (d Date) After(d2 Date) bool

After reports whether dt occurs after dt2.

func (Date) Before

func (d Date) Before(d2 Date) bool

Before reports whether dt occurs before dt2.

func (Date) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface. The time is a quoted string.

func (Date) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface. The output is the result of d.String().

func (*Date) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string.

func (*Date) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface. The date is expected to be a string in a format accepted by ParseDate.

type DateRange

type DateRange struct {
	Start time.Time
	End   time.Time
}

DateRange represents a range between two dates

func MonthsBetweenDates

func MonthsBetweenDates(start time.Time, end time.Time) []DateRange

MonthsBetweenDates returns full calendar months matching the given start and end dates

type DateTime

type DateTime struct {
	civil.DateTime
}

DateTime is a native date time in YYYY-MM-DD HH:MM:SS format

func DateTimeOf

func DateTimeOf(t time.Time) DateTime

DateTimeOf constructs a DateTime type from given time

func ParseDateTime

func ParseDateTime(str string) (DateTime, error)

ParseDateTime returns a DateTime type parsed from a string

func (DateTime) After

func (dt DateTime) After(dt2 DateTime) bool

After reports whether dt occurs after dt2.

func (DateTime) Before

func (dt DateTime) Before(dt2 DateTime) bool

Before reports whether dt occurs before dt2.

func (DateTime) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface. The time is a quoted string.

func (DateTime) MarshalText

func (dt DateTime) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The output is the result of dt.String().

func (DateTime) String

func (dt DateTime) String() string

String returns the date in the format described in ParseDate.

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string.

func (*DateTime) UnmarshalText

func (dt *DateTime) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The date is expected to be a string in a format accepted by ParseDate.

Jump to

Keyboard shortcuts

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