util

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package util provides small shared helpers: date parsing and date-range validation.

Index

Constants

View Source
const MaxDateRangeDays = 93

MaxDateRangeDays is the default maximum span accepted by DateRange.Validate.

Variables

View Source
var (
	ErrNotSunday         = errors.New("date must be a Sunday")
	ErrFromAfterTo       = errors.New("'from' must be before 'to'")
	ErrDateRangeExceeded = errors.New("date range exceeded")
)

Functions

func ParseSundayDate added in v1.3.15

func ParseSundayDate(value string) (time.Time, error)

ParseSundayDate parses value in "2006-01-02" format and verifies it falls on a Sunday, returning ErrNotSunday otherwise.

func ValidateDateRange added in v1.3.19

func ValidateDateRange(from, to time.Time, maxDays int) error

ValidateDateRange checks that from precedes to and the span does not exceed maxDays.

func ValidateSunday

func ValidateSunday(value string) error

ValidateSunday reports whether value is a valid "2006-01-02" date falling on a Sunday.

Types

type DateRange added in v1.3.19

type DateRange struct {
	From    time.Time
	To      time.Time
	MaxDays int
}

DateRange is an inclusive [From, To] interval. MaxDays bounds the span; zero means MaxDateRangeDays.

func (DateRange) Validate added in v1.3.19

func (dr DateRange) Validate() error

Validate checks that From precedes To and the span does not exceed MaxDays.

Jump to

Keyboard shortcuts

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