frdate

package
v0.0.0-...-fb74ee3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package frdate has functions to manage reservation dates and record timestamps.

In general the fr code should not use time package but only these functions.

Also this package should not accept or return "time" objects.

Date or DateTime objects are used for calendar dates and timestamps respectively.

Date or DateTime objects are built with a DataBuilder which requires the location.

Date objects are persisted with strings in the iso8601format layout (see below).

DateTime objects are persisted with strings in the time.RFC3339 layout (see time package).

Index

Constants

This section is empty.

Variables

View Source
var TestTimeOffsetDays *int

TestTimeOffsetDays is the time offset used during testing

Functions

func CreateDateTimeUTC

func CreateDateTimeUTC() string

CreateDateTimeUTC is used for all timestamps in the project

func DateOverlap

func DateOverlap(first1 *Date, last1 *Date, first2 *Date, last2 *Date) bool

DateOverlap returns true if there exists an overlap between the first and second date ranges

func DateOverlapInOut

func DateOverlapInOut(inDate1 *Date, outDate1 *Date, inDate2 *Date, outDate2 *Date) bool

DateOverlapInOut returns true if there exists an overlap between the first and last in-out date ranges

Types

type Date

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

Date represents a calendar date

func DaysList

func DaysList(first *Date, last *Date, includeLast bool) ([]*Date, error)

DaysList returns a list of Date's inclusive or exclusive of the last Date argument

func MustNewDate

func MustNewDate(location string, iso8601short string) *Date

MustNewDate produces a Date given a location and date string or panics on error

func (*Date) AddDays

func (r *Date) AddDays(num int) *Date

AddDays returns the Date after num days

func (*Date) After

func (r *Date) After(date *Date) bool

After is true if the passed Date is after the receiver Date

func (*Date) Before

func (r *Date) Before(date *Date) bool

Before is true if the passed Date is before the receiver Date

func (*Date) Copy

func (r *Date) Copy() *Date

Copy returns a copy of the receiver Date

func (*Date) Equal

func (r *Date) Equal(date *Date) bool

Equal is true if the passed Date is equal to the receiver Date

func (*Date) Format

func (r *Date) Format(layout string) string

Format produces a string representation of a Date based on the layout argument

func (*Date) MonthInOut

func (r *Date) MonthInOut() (*Date, *Date)

MonthInOut produces the first Date of the current month, and the first Date of the following month

func (*Date) Sub

func (r *Date) Sub(start *Date) int

Sub returns the number of days between two dates

func (*Date) ToString

func (r *Date) ToString() string

ToString returns the iso string representation of a Date

func (*Date) ToStringPtr

func (r *Date) ToStringPtr() *string

ToStringPtr returns a pointer to an iso string representation of a Date

func (*Date) Year

func (r *Date) Year() int

Year returns the year portion of a Date

func (*Date) YearInOut

func (r *Date) YearInOut() (*Date, *Date)

YearInOut produces the first Date of the current year and the first Date of the following year

type DateBuilder

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

DateBuilder is the base struct for creating Date or DateTime objects

func MustNewDateBuilder

func MustNewDateBuilder(location string) *DateBuilder

MustNewDateBuilder creates a new DateBuilder given a location or panics on error

func NewDateBuilder

func NewDateBuilder(location string) (*DateBuilder, error)

NewDateBuilder creates a new DateBuilder given a location or returns an error

func (*DateBuilder) MustNewDate

func (r *DateBuilder) MustNewDate(iso8601short string) *Date

MustNewDate produces a Date given the date string, or panics

func (*DateBuilder) MustNewDateTime

func (r *DateBuilder) MustNewDateTime(rfc3339datetime string) *DateTime

MustNewDateTime produces a DateTime given the date-time string, or panics

func (*DateBuilder) NewDate

func (r *DateBuilder) NewDate(iso8601short string) (*Date, error)

NewDate produces a Date given the date string, or returns an error

func (*DateBuilder) NewDateTime

func (r *DateBuilder) NewDateTime(rfc3339datetime string) (*DateTime, error)

NewDateTime produces a DateTime given the date-time string, or returns an error

func (*DateBuilder) Today

func (r *DateBuilder) Today() *Date

Today produces today's Date

type DateTime

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

DateTime represents a date plus time, ex. for use as a timestamp

func (*DateTime) AddDays

func (r *DateTime) AddDays(num int) *DateTime

AddDays returns the DateTime after num days

func (*DateTime) After

func (r *DateTime) After(date *DateTime) bool

After is true if the passed DateTime is after the receiver DateTime

func (*DateTime) Before

func (r *DateTime) Before(date *DateTime) bool

Before is true if the passed DateTime is before the receiver DateTime

func (*DateTime) Equal

func (r *DateTime) Equal(date *DateTime) bool

Equal is true if the passed DateTime is equal to the receiver DateTime

func (*DateTime) Format

func (r *DateTime) Format(layout string) string

Format produces a string representation of a DateTime based on the layout argument

func (*DateTime) ToDate

func (r *DateTime) ToDate() *Date

ToDate returns the Date of a DateTime

func (*DateTime) ToString

func (r *DateTime) ToString() string

ToString returns the rfc string representation of a DateTime

func (*DateTime) ToStringPtr

func (r *DateTime) ToStringPtr() *string

ToStringPtr returns a pointer to an rfc string representation of a DateTime

Jump to

Keyboard shortcuts

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