date

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package date contains the Date datatype.

Index

Constants

This section is empty.

Variables

View Source
var Epoch = Date{1970, time.January, 1}

Epoch is the Date value for the Unix epoch. It is used as a stand-in for missing dates.

Functions

This section is empty.

Types

type Date

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

Date represents a calendar date. It's similar to time.Time, but it carries no information neither about the time of day nor about the timezone.

func FromTime

func FromTime(t time.Time) Date

FromTime converts a time.Time into its Date.

func Now

func Now() Date

Now returns the current Date.

func Parse

func Parse(input string) (Date, error)

Parse parses a date string in the format "yyyy-mm-dd".

func (Date) AddDays

func (d Date) AddDays(days int) Date

AddDays shifts this date by that many days into the future (or into the past, if the number of days is negative).

func (Date) After

func (d Date) After(other Date) bool

After returns whether this date is after the other one.

func (Date) Before

func (d Date) Before(other Date) bool

Before returns whether this date is before the other one.

func (Date) FirstSecondIn

func (d Date) FirstSecondIn(loc *time.Location) time.Time

FirstSecondIn returns a timestamp representing the second when the day with this Date starts in the given timezone.

func (*Date) Scan

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

Scan implements the database/sql.Scanner interface.

func (Date) String

func (d Date) String() string

String returns this date in the format "yyyy-mm-dd".

func (Date) Sub

func (d Date) Sub(other Date) int

Sub returns the number of days between this date and the other one. If `other.After(d)`, the return value is negative.

func (Date) Value

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

Value implements the database/sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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