datespec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: CC0-1.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package datespec resolves relative dates and clock spans against an explicit civil-date reference, without reading a clock or performing I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LastWeek

func LastWeek(r Ref) (from, to civil.Date)

LastWeek returns the inclusive full week immediately before Week(r).

func Month

func Month(r Ref) (from, to civil.Date)

Month returns the inclusive full calendar month containing r.Today. A zero reference date returns zero dates.

func Parse

func Parse(s string, m Mode, r Ref) (domain.Moment, error)

Parse resolves a date with an optional clock, or a bare clock on today. Keywords are case-insensitive and surrounding whitespace is ignored.

func ParseClock

func ParseClock(s string, allow2400 bool) (civil.Minute, error)

ParseClock parses H:MM or HH:MM, trimming surrounding whitespace. The clock 24:00 is accepted only when allow2400 is true.

func ParseSpan

func ParseSpan(s string, m Mode, r Ref) (domain.BlockSpan, error)

ParseSpan resolves an optional date followed by start-end clocks, defaulting to today. The span must satisfy 0 <= start < end <= 1440, with no spaces around the hyphen. Only the end clock may be 24:00.

func Week

func Week(r Ref) (from, to civil.Date)

Week returns the inclusive full week containing r.Today, starting on r.WeekStart. The reference must contain a valid date and weekday.

Types

type InputError

type InputError struct {

	// NamesBlock reports whether the diagnostic itself identifies a block span or endpoint.
	NamesBlock bool
	// BareClock reports that the diagnostic starts with the offending clock value.
	BareClock bool
	// contains filtered or unexported fields
}

InputError keeps historical problem JSON available to the CLI while Error describes an input failure without implementation prefixes.

func (*InputError) Error

func (e *InputError) Error() string

func (*InputError) ProblemDetail

func (e *InputError) ProblemDetail() string

ProblemDetail returns the original detail used in machine-readable errors. AIDEV-NOTE: CLI --json depends on this detail even when Error changes.

type Mode

type Mode uint8

Mode selects how weekday names are resolved relative to today.

const (
	// Past selects the most recent weekday, including today.
	Past Mode = iota + 1
	// Future selects the next weekday, excluding today.
	Future Mode = iota + 1
)

type Ref

type Ref struct {
	Today     civil.Date
	WeekStart time.Weekday
}

Ref supplies the current civil date and configured first day of the week.

Jump to

Keyboard shortcuts

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