dates

package module
v0.0.0-...-2498913 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

README

dates

Package dates provides a data type for just dates (without time) named Date which is a moment in time specified by only year month day. Also, Date does have some basic validity checks but does not check for invalid combinations like 29 February on a non leap year or so. Date is closer to how string works, rather than how time.Time works. For the real thing, you probably want to use time.Time, however Date is easy for simple things.

Documentation

Index

Constants

View Source
const ISO8601Date = "2006-01-02"

ISO8601Date is a format string for ISO8601 yyyy-MM-dd date format.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

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

Date represents a moment in time specified by year, month and day.

func New

func New(year int, month int, day int) (Date, error)

New constructs a new Date from the specified values.

func Parse

func Parse(format string, input string) (Date, error)

Parse constructs a new date from the input string accepting format similar to time.Parse, but limited to: 2006 for year, 01 for month, and 02 for day.

func (Date) Day

func (d Date) Day() int

Day returns the day part of date.

func (*Date) MarshalText

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

MarshalText allows Date to marshal itself into a textual form, for example to JSON or XML.

func (Date) Month

func (d Date) Month() int

Month returns the month part of date.

func (Date) String

func (d Date) String() string

String returns the date in ISO8601 yyyy-MM-dd format.

func (*Date) UnmarshalText

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

UnmarshalText allows Date to unmarshal a textual representation of itself, for example from JSON or XML.

func (Date) Year

func (d Date) Year() int

Year returns the year part of date.

Jump to

Keyboard shortcuts

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