r3when

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package r3when is the bridge between the years schedule vocabulary and r3 filters. It compiles recurring weekly wall-clock patterns (schedule.WeekPatterns) into r3.Filters built from the vocabulary-free OperatorWeekdayIn and OperatorTimeOfDayBetween primitives, and resolves human terms ("weekends", "mornings") into those patterns via years.

It is a dialect in the same sense as the URL or JSON dialects: it translates an external, human representation of a filter into the r3 query model. Keeping it here - not in the r3 core - is what lets the core stay free of the years dependency and free of any time vocabulary. r3 knows how to compare time components; only this dialect knows that "weekends" means Saturday and Sunday.

The compiled filters use nothing but root filter vocabulary, so they serialize through every r3 dialect and run on any engine that lowers the two operators (the file engine and Mongo today; SQL once the flavor hook lands - see docs/plan-when-filters.md).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filters

func Filters(field string, ps schedule.WeekPatterns) r3.Filters

Filters compiles a union of week patterns into r3 filters against field. The union is an OR of per-pattern groups; each pattern is a conjunction of its weekday set and its time-of-day spans. An empty pattern set - or any pattern that matches every instant - compiles to nil (no filter), since an OR with a match-everything member matches everything.

The output uses only root filter vocabulary (WeekdayIn / TimeOfDayBetween and And/Or groups), so it serializes through every dialect and runs on any engine that lowers those operators.

func Parse

func Parse(field, expr string) (r3.Filters, error)

Parse resolves a vocabulary expression ("weekends", "mornings,evenings") into r3 filters against field, using the default years vocabulary. The years error (which lists the known terms) is passed through unchanged - it is user-facing and belongs verbatim in an HTTP 400.

func ParseWith

func ParseWith(v schedule.Vocabulary, field, expr string) (r3.Filters, error)

ParseWith is Parse with a caller-supplied vocabulary, for apps that add domain terms or a custom day partition.

Types

This section is empty.

Jump to

Keyboard shortcuts

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