date

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: BSD-3-Clause Imports: 4 Imported by: 3

README

date

Minimal utility functions for working with SQL dates and other date-only dates in Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date time.Time

Date represents a date with no time or timezone information. It is compatible with PostgreSQL database DATE values when using the de facto standard lib/pq driver.

func FromTime

func FromTime(t time.Time) Date

FromTime constructs a new Date object from the provided time.Time value, throwing away all time and timezone information.

func NewDate

func NewDate(y, m, d int) Date

NewDate constructs a new Date object for the given year, month and day

func (*Date) AddDate

func (d *Date) AddDate(yy int, mm int, dd int) Date

AddDate adds the specified number of years, months and days to the Date, returning another Date.

func (*Date) After

func (d *Date) After(other Date) bool

After returns true if the first date (the reciever) is after the second date (the argument).

func (*Date) Before

func (d *Date) Before(other Date) bool

Before returns true if the first date (the reciever) is before the second date (the argument).

func (*Date) Equal

func (d *Date) Equal(other Date) bool

Equal returns true if the two dates are equal.

func (*Date) MarshalJSON

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

MarshalJSON marshals a Date into JSON format. The date is formatted in RFC 3339 full-date format -- that is, yyyy-mm-dd.

func (*Date) Scan

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

Scan implements the database/sql Scanner interface.

func (*Date) String

func (d *Date) String() string

String returns the value of the Date in ISO-8601 / RFC 3339 format yyyy-mm-dd.

func (*Date) UnmarshalJSON

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

UnmarshalJSON unmarshals a Date from JSON format. The date is expected to be in full-date format as per RFC 3339 -- that is, yyyy-mm-dd.

func (Date) Value

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

Value implements the database/sql Valuer interface.

Jump to

Keyboard shortcuts

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