cal

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Overview

Package cal provides simple date handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateAfter

func DateAfter(date Date) validation.Rule

DateAfter returns a validation rule which checks to ensure the date is *after* the provided date.

func DateBefore

func DateBefore(date Date) validation.Rule

DateBefore is used during validation to ensure the date is before the value passed in.

func DateNotZero

func DateNotZero() validation.Rule

DateNotZero ensures the date is not a zero value.

Types

type Date

type Date struct {
	civil.Date
}

Date represents a simple date without time used most frequently with business documents.

func MakeDate

func MakeDate(year int, month time.Month, day int) Date

MakeDate provides a new date instance.

func NewDate

func NewDate(year int, month time.Month, day int) *Date

NewDate provides a pointer to a new date instance.

func Today added in v0.40.0

func Today() Date

Today generates a new date instance for today.

func TodayIn added in v0.40.0

func TodayIn(loc *time.Location) Date

TodayIn generates a new date instance for today in the given location.

func (Date) JSONSchema

func (Date) JSONSchema() *jsonschema.Schema

JSONSchema returns a custom json schema for the date.

func (*Date) UnmarshalJSON added in v0.39.0

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

UnmarshalJSON is used to parse a date from json and ensures that we can handle invalid data reasonably.

func (Date) Validate added in v0.39.0

func (d Date) Validate() error

Validate ensures the the date object looks valid.

type Period

type Period struct {
	// Label is a short description of the period.
	Label string `json:"label,omitempty" jsonschema:"title=Label"`
	// Start indicates when this period starts.
	Start Date `json:"start"`
	// End indicates when the period ends, and must be after the start date.
	End Date `json:"end"`
}

Period represents two dates with a start and finish.

func (*Period) Validate

func (p *Period) Validate() error

Validate checks to ensure the period looks correct.

Jump to

Keyboard shortcuts

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