date

package module
v0.0.0-...-765a9dd Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

README

date build status GoDoc

go get github.com/Hunsin/date

A basic implementation of date type in Golang. Godoc

The date type may be implemented in Golang 2.

Update: civil package may be part of Golang x packages. We'll see.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

A Date specifies the year, month and day.

func Now

func Now() Date

Now returns the current local date.

func Of

func Of(t time.Time) Date

Of returns the Date of t in t's location.

func Parse

func Parse(layout, d string) (Date, error)

Parse parses the d with layout and returns the value of Date. The layout follows the format of time.Parse.

func (Date) After

func (d Date) After(t Date) bool

After reports whether d is after t.

func (Date) Before

func (d Date) Before(t Date) bool

Before reports whether d is before t.

func (Date) Equal

func (d Date) Equal(t Date) bool

Equal reports whether d and t are the same date.

func (Date) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface. The output is in "YYYY-MM-DD" format.

func (*Date) Scan

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

Scan implements the sql.Scanner interface.

func (Date) String

func (d Date) String() string

String returns a string of date in "YYYY-MM-DD" format.

func (Date) Sub

func (d Date) Sub(t Date) int

Sub returns the days d - t.

func (*Date) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface. The formats it supports are "2006-01-02", "2006/01/02" and "02 Jan 2006".

func (Date) Value

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