timex

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package timex contained time-related extensions, notably representations of a Date without a time, and a MonthYear without a day.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MonthsBetween

func MonthsBetween(from, to MonthYear) int

MonthsBetween returns the number of months between two (month, year)

func MustParseTime

func MustParseTime(layout, s string) time.Time

MustParseTime parses the given string according to the provided layout, panicking if the time cannot be parsed. Useful for tests.

Types

type Date

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

A Date is a month, day, year.

func MustParseDate

func MustParseDate(s string) Date

MustParseDate parses a date, panicking if the date can't be parsed. Useful for tests.

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate parses a date.

func (Date) After added in v0.1.1

func (d Date) After(other Date) bool

After returns true if this date is after another.

func (Date) Before added in v0.1.1

func (d Date) Before(other Date) bool

Before returns true if this date is before another date.

func (Date) CompareTo

func (d Date) CompareTo(other Date) int

CompareTo compares this date to another;

func (Date) DayEnd

func (d Date) DayEnd() time.Time

DayEnd returns the time at the end of the day, in UTC.

func (Date) DayStart

func (d Date) DayStart() time.Time

DayStart returns the time at the start of the day, in UTC.

func (Date) Equal added in v0.1.1

func (d Date) Equal(other Date) bool

Equal returns true if this date is equal to another date.

func (Date) IsZero added in v0.1.3

func (d Date) IsZero() bool

IsZero returns true if the date value is not set.

func (Date) Less

func (d Date) Less(other Date) bool

Less returns true if this date is earlier than the other date.

func (Date) NextDay

func (d Date) NextDay() Date

NextDay returns the next day.

func (Date) String

func (d Date) String() string

String returns a string format of the date.

func (*Date) UnmarshalText

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

UnmarshalText unmarshalls the date from a text value. Implements the TextUnmarshaler interface.

type MonthYear

type MonthYear struct {
	Month time.Month
	Year  int
}

MonthYear is a month and year combination.

func MustParseMonthYear

func MustParseMonthYear(s string) MonthYear

MustParseMonthYear parses a month-year, panicking if the month-year cannot be parsed. Useful for tests.

func ParseMonthYear

func ParseMonthYear(s string) (MonthYear, error)

ParseMonthYear parses a month-year.

func (MonthYear) After added in v0.1.1

func (my MonthYear) After(other MonthYear) bool

After returns true if this date is after another.

func (MonthYear) Before added in v0.1.1

func (my MonthYear) Before(other MonthYear) bool

Before returns true if this date is before another date.

func (MonthYear) CompareTo

func (my MonthYear) CompareTo(other MonthYear) int

CompareTo compares two (month, year). Returns:

-1 if this MonthYear is earlier than the provided MonthYear
1 if this MonthYear is later than the provided MonthYear
0 if this MonthYear is the same as the provided MonthYear

func (MonthYear) Equal added in v0.1.1

func (my MonthYear) Equal(other MonthYear) bool

Equal returns true if this date is equal to another date.

func (MonthYear) IsZero added in v0.1.3

func (my MonthYear) IsZero() bool

IsZero returns true if the month/year is not set.

func (MonthYear) Less

func (my MonthYear) Less(other MonthYear) bool

Less returns true if the MonthYear is earlier than the provided MonthYear.

func (MonthYear) MonthEnd

func (my MonthYear) MonthEnd() Date

MonthEnd returns the date that is the end of the month.

func (MonthYear) MonthStart

func (my MonthYear) MonthStart() Date

MonthStart returns the date that is the start of the month.

func (MonthYear) NextMonth

func (my MonthYear) NextMonth() MonthYear

NextMonth returns the next month.

func (MonthYear) String

func (my MonthYear) String() string

String returns a string format of the MonthYear

func (*MonthYear) UnmarshalText

func (my *MonthYear) UnmarshalText(text []byte) error

UnmarshalText unmarshalls the date from a text value. Implements the TextUnmarshaler interface.

Jump to

Keyboard shortcuts

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