openinghours

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 16 Imported by: 0

README

opening-hours

CI CodeQL Coverage Mutation Documentation Go Reference Release Go License

Immutable, deterministic, timezone-safe recurring opening hours and dated exceptions for Go 1.26.6 and later.

Install the stable root module with:

go get github.com/faustbrian/go-opening-hours@v1.1.0

The package models generic availability for service points, storefronts, offices, pickup locations, and support desks. It does not parse carrier prose, book appointments, plan workforces, or decide whether an order is eligible.

Five-minute start

package main

import (
	"fmt"
	"time"

	openinghours "github.com/faustbrian/go-opening-hours"
)

func main() {
	start, _ := openinghours.NewLocalTime(9, 0, 0, 0)
	end, _ := openinghours.NewLocalTime(17, 0, 0, 0)
	dayRange, _ := openinghours.NewRange(start, end)
	monday, _ := openinghours.OpenRanges(
		[]openinghours.Range{dayRange},
		openinghours.RejectOverlapAndAdjacent,
	)

	schedule, _ := openinghours.NewSchedule(openinghours.Config{
		Timezone: "Europe/Helsinki",
		Weekly: map[time.Weekday]openinghours.DayRule{
			time.Monday: monday,
		},
	})

	result, _ := schedule.IsOpen(
		time.Date(2026, time.January, 5, 10, 0, 0, 0, time.UTC),
	)
	fmt.Println(result.Open, result.Explanation.Timezone)
}

All boundaries are start-inclusive and end-exclusive. A range such as 22:00-02:00 belongs to its start date. The zero Schedule is closed and has no timezone; it never means always open.

What is explicit

  • IANA timezone identity and DST gap/fold policy
  • inherited, ranged, all-day, and closed day states
  • overlap, adjacency, and normalization policy
  • exact-date replace, add, subtract, and close operations
  • exception priority, source, revision, and optional named set
  • inclusive effective dates and outside-range behavior
  • bounded transition horizons, output counts, parsing, and composition depth
  • canonical JSON, stable comparison/hash, separate human display summaries
  • SQL/JSONB persistence and native pgx behavior
  • injected clocks and privacy-safe observation callbacks

Packages

Package Purpose
root Values, rules, exceptions, algebra, queries, encoding, SQL
adapters/calendar Calendar dates and bounded holiday closures
adapters/config Strict configuration values
adapters/temporal Lossless Temporal time-of-day conversion
adapters/validation Shared Validation contract
adapters/wire Canonical byte codec for Wire registries
compile Immutable prepared query handle
encoding Canonical Location/Spatie imports; Track/Postal fixtures
openinghourstest Panic-on-error test builders
postgres Domain-owned nullable JSONB and pgx schedule mapping

The released openinghourscalendar, openinghoursconfig, openinghourstemporal, openinghoursvalidation, and openinghourswire packages remain compatibility facades. New code should use the corresponding adapters/<target> path. See the migration guide.

Documentation

Start at the documentation index. The five-minute guides cover weekly schedules, exceptions, overnight ranges, timezones, and queries. The formal contracts are in precedence and normalization. Owned-module integration is covered in integrations.

For ecosystem-wide selection and ownership guidance, see the versioned Golib ecosystem index and its Domain utilities family.

Local verification

make check

make check runs the complete shared-library contract, including formatting, tests, race detection, exact coverage, mutation verification, fuzzing, benchmarks, API compatibility, documentation, security, and the typed timezone regression operation. Package-specific services are task-owned by the shared tool; PostgreSQL integration is enabled by the module manifest.

Support and policy

See security policy, contribution guide, compatibility policy, and changelog. The project is available under the MIT License.

Documentation

Overview

Package openinghours provides immutable recurring opening-hours schedules, dated exceptions, explicit timezone evaluation, bounded search, and stable canonical persistence.

Index

Constants

View Source
const (
	// MaxCompositionDepth bounds immutable algebra expression nesting.
	MaxCompositionDepth = 16
)
View Source
const (
	// MaxHumanSummaryBytes bounds presentation-oriented schedule summaries.
	MaxHumanSummaryBytes = 64 << 10
)
View Source
const (
	// MaxJSONBytes bounds canonical and parsed schedule documents.
	MaxJSONBytes = 1 << 20
)

Variables

This section is empty.

Functions

func IsCode

func IsCode(err error, code Code) bool

IsCode reports whether err or an error in its chain has code.

Types

type Availability

type Availability struct {
	Open        bool
	Explanation Explanation
}

Availability is the explained result of a point query.

type Clock

type Clock = clock.Clock

Clock is the clock current-time capability. Core schedule queries never read a process-global clock.

type Code

type Code string

Code identifies a stable, safe-to-expose failure category.

const (
	// CodeInvalidTime reports a wall-clock value outside its valid domain.
	CodeInvalidTime Code = "invalid_time"
	// CodeInvalidDate reports a civil date outside its valid domain.
	CodeInvalidDate Code = "invalid_date"
	// CodeInvalidRange reports a malformed or zero-length time range.
	CodeInvalidRange Code = "invalid_range"
	// CodeInvalidTimezone reports an absent or unknown IANA timezone.
	CodeInvalidTimezone Code = "invalid_timezone"
	// CodeInvalidWeekday reports a weekday outside Sunday through Saturday.
	CodeInvalidWeekday Code = "invalid_weekday"
	// CodeInvalidState reports an unsupported enum or state combination.
	CodeInvalidState Code = "invalid_state"
	// CodeOverlap reports overlapping ranges under a rejecting policy.
	CodeOverlap Code = "overlap"
	// CodeLimitExceeded reports a configured resource bound was exceeded.
	CodeLimitExceeded Code = "limit_exceeded"
	// CodeAmbiguousException reports equal-priority exception ambiguity.
	CodeAmbiguousException Code = "ambiguous_exception"
	// CodeDuplicateRevision reports duplicate source revision identity.
	CodeDuplicateRevision Code = "duplicate_revision"
	// CodeAmbiguousLocalTime reports a local time in a timezone fold.
	CodeAmbiguousLocalTime Code = "ambiguous_local_time"
	// CodeNonexistentLocalTime reports a local time in a timezone gap.
	CodeNonexistentLocalTime Code = "nonexistent_local_time"
	// CodeInvalidHorizon reports an unbounded or excessive search horizon.
	CodeInvalidHorizon Code = "invalid_horizon"
	// CodeSearchExhausted reports no transition in the bounded horizon.
	CodeSearchExhausted Code = "search_exhausted"
	// CodeTimezoneMismatch reports composition across different timezones.
	CodeTimezoneMismatch Code = "timezone_mismatch"
	// CodeInvalidEncoding reports malformed or noncanonical input structure.
	CodeInvalidEncoding Code = "invalid_encoding"
	// CodeUnsupportedVersion reports an unknown canonical wire version.
	CodeUnsupportedVersion Code = "unsupported_version"
	// CodeInvalidInterval reports a reversed, empty, or excessive interval.
	CodeInvalidInterval Code = "invalid_interval"
	// CodeOutsideEffectiveRange reports a query outside configured dates.
	CodeOutsideEffectiveRange Code = "outside_effective_range"
	// CodeInvalidClock reports a missing injected clock capability.
	CodeInvalidClock Code = "invalid_clock"
	// CodeAdjacent reports adjacent ranges under a rejecting policy.
	CodeAdjacent Code = "adjacent"
	// CodeDayBoundaryOverflow reports normalized ownership beyond one day.
	CodeDayBoundaryOverflow Code = "day_boundary_overflow"
)

type Config

type Config struct {
	Timezone         string
	Weekly           map[time.Weekday]DayRule
	Exceptions       []Exception
	ExceptionSets    []ExceptionSet
	ConflictPolicy   ConflictPolicy
	Metadata         Metadata
	EffectiveStart   *Date
	EffectiveEnd     *Date
	OutsideEffective OutsideEffectivePolicy
}

Config is copied by NewSchedule.

type ConflictPolicy

type ConflictPolicy uint8

ConflictPolicy controls equal-priority exception handling.

const (
	// RejectAmbiguous rejects equal-priority rules without unique precedence.
	RejectAmbiguous ConflictPolicy = iota
	// ResolveCanonical resolves equal priorities by stable provenance order.
	ResolveCanonical
)

type DailyRange

type DailyRange struct {
	Start            LocalTime
	End              LocalTime
	EndAtDayBoundary bool
}

DailyRange is a start-inclusive, end-exclusive interval within one civil date. EndAtDayBoundary distinguishes midnight at the end from midnight at the start of the date.

type Date

type Date = calendar.Date

Date is the calendar immutable Gregorian civil date value.

func MustDate

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

MustDate returns a valid date or panics. It is intended for static fixtures.

func NewDate

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

NewDate validates and constructs a Gregorian civil date.

type DayResult

type DayResult struct {
	State  DayState
	Ranges []Range
}

DayResult is a detached result safe for caller mutation.

type DayRule

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

DayRule is an immutable weekly or dated availability rule.

func Closed

func Closed() DayRule

Closed returns an explicit closure rule.

func Inherited

func Inherited() DayRule

Inherited returns a rule that delegates to the lower-precedence source.

func OpenAllDay

func OpenAllDay() DayRule

OpenAllDay returns an explicit full-day rule.

func OpenRanges

func OpenRanges(input []Range, policy OverlapPolicy) (DayRule, error)

OpenRanges constructs a canonical ranged rule using the selected policy.

func (DayRule) Ranges

func (rule DayRule) Ranges() []Range

Ranges returns a detached copy of canonical ranges.

func (DayRule) State

func (rule DayRule) State() DayState

State returns the explicit day state.

type DayState

type DayState uint8

DayState distinguishes absence, ranged opening, full-day opening, and closure.

const (
	// DayInherited delegates to a lower-precedence rule source.
	DayInherited DayState = iota
	// DayOpenRanges opens only the rule's explicit local-time ranges.
	DayOpenRanges
	// DayOpenAllDay opens the complete owned civil day.
	DayOpenAllDay
	// DayClosed explicitly closes the owned civil day.
	DayClosed
)

type ElapsedClock

type ElapsedClock = clock.ElapsedClock

ElapsedClock is the clock monotonic elapsed-time capability. Observation helpers accept it separately so measuring a query never reads wall time.

type Error

type Error struct {
	Code Code
	Op   string
}

Error is a bounded package error. It never embeds schedule or input data.

func (*Error) Error

func (e *Error) Error() string

type Exception

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

Exception is an immutable exact-date availability operation.

func NewException

func NewException(config ExceptionConfig) (Exception, error)

NewException validates an exact-date exception and its bounded provenance.

func (Exception) Date

func (e Exception) Date() Date

Date returns the exact exception date.

func (Exception) Operation

func (e Exception) Operation() ExceptionOperation

Operation returns the exception operation.

func (Exception) Priority

func (e Exception) Priority() int

Priority returns the deterministic precedence priority.

func (Exception) Revision

func (e Exception) Revision() string

Revision returns bounded provenance revision.

func (Exception) Rule

func (e Exception) Rule() DayRule

Rule returns a detached immutable rule.

func (Exception) Set

func (e Exception) Set() string

Set returns the optional named exception set.

func (Exception) Source

func (e Exception) Source() string

Source returns bounded provenance.

type ExceptionConfig

type ExceptionConfig struct {
	Date      Date
	Operation ExceptionOperation
	Rule      DayRule
	Priority  int
	Source    string
	Revision  string
}

ExceptionConfig is copied by NewException.

type ExceptionOperation

type ExceptionOperation uint8

ExceptionOperation defines how a dated rule changes inherited availability.

const (
	// ExceptionReplace replaces availability for its civil date.
	ExceptionReplace ExceptionOperation = iota
	// ExceptionAdd unions availability into its civil date.
	ExceptionAdd
	// ExceptionSubtract removes availability from its civil date.
	ExceptionSubtract
	// ExceptionClose closes its civil date completely.
	ExceptionClose
)

type ExceptionRangeConfig

type ExceptionRangeConfig struct {
	Name         string
	Start        Date
	End          Date
	MaximumDates int
	Operation    ExceptionOperation
	Rule         DayRule
	Priority     int
	Source       string
	Revision     string
}

ExceptionRangeConfig expands a bounded inclusive civil-date range.

type ExceptionSet

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

ExceptionSet is an immutable named group flattened before evaluation.

func ExpandExceptionRange

func ExpandExceptionRange(config ExceptionRangeConfig) (ExceptionSet, error)

ExpandExceptionRange resolves a multi-day rule to deterministic exact dates.

func NewExceptionSet

func NewExceptionSet(name string, input []Exception) (ExceptionSet, error)

NewExceptionSet validates, names, and copies a non-empty exception group.

func (ExceptionSet) Exceptions

func (set ExceptionSet) Exceptions() []Exception

Exceptions returns detached exception values and range slices.

func (ExceptionSet) Name

func (set ExceptionSet) Name() string

Name returns the bounded set name.

type Explanation

type Explanation struct {
	Rule     RuleKind
	Timezone string
	Source   string
	Revision string
}

Explanation reports bounded, non-sensitive rule provenance.

type InstantRange

type InstantRange struct {
	Start time.Time
	End   time.Time
}

InstantRange is a start-inclusive, end-exclusive absolute interval.

type LocalKind

type LocalKind uint8

LocalKind classifies a local-to-instant conversion.

const (
	// LocalExact identifies a local time with exactly one corresponding instant.
	LocalExact LocalKind = iota
	// LocalGap identifies a local time shifted through a timezone gap.
	LocalGap
	// LocalFold identifies a local time selected from a timezone fold.
	LocalFold
)

type LocalResolutionPolicy

type LocalResolutionPolicy uint8

LocalResolutionPolicy explicitly resolves DST gaps and folds.

const (
	// RejectDST rejects both nonexistent and ambiguous local times.
	RejectDST LocalResolutionPolicy = iota
	// PreferEarlier selects the earlier instant in a local-time fold.
	PreferEarlier
	// PreferLater selects the later instant in a local-time fold.
	PreferLater
	// ShiftForward advances a nonexistent local time through a timezone gap.
	ShiftForward
)

type LocalTime

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

LocalTime is a nanosecond-precision wall-clock time without a date or zone. Its zero value is midnight.

func NewLocalTime

func NewLocalTime(hour, minute, second, nanosecond int) (LocalTime, error)

NewLocalTime constructs a wall-clock time in the half-open day [00:00,24:00).

func (LocalTime) Hour

func (t LocalTime) Hour() int

Hour returns the hour component.

func (LocalTime) Minute

func (t LocalTime) Minute() int

Minute returns the minute component.

func (LocalTime) Nanosecond

func (t LocalTime) Nanosecond() int

Nanosecond returns the fractional second component.

func (LocalTime) Second

func (t LocalTime) Second() int

Second returns the second component.

type Metadata

type Metadata struct {
	Label    string
	Source   string
	Revision string
}

Metadata carries bounded provenance and has no interval semantics.

type Observation

type Observation struct {
	Operation   Operation
	Outcome     Outcome
	RangeCount  int
	SearchSteps int
	Duration    time.Duration
}

Observation contains only bounded operational data. It intentionally has no schedule label, source, revision, date, timezone, or customer fields.

type Observer

type Observer func(Observation)

Observer receives one completed observation outside any lock. Panics are contained and cannot alter the query result.

type Operation

type Operation uint8

Operation identifies an observable package operation.

const (
	// OperationIsOpen identifies an observed instant availability query.
	OperationIsOpen Operation = iota
	// OperationNextTransition identifies an observed transition search.
	OperationNextTransition
)

type Outcome

type Outcome uint8

Outcome is a bounded, non-sensitive operation result.

const (
	// OutcomeClosed reports a successful query whose resource is closed.
	OutcomeClosed Outcome = iota
	// OutcomeOpen reports a successful query whose resource is open.
	OutcomeOpen
	// OutcomeFound reports a transition found within the search horizon.
	OutcomeFound
	// OutcomeError reports a typed query or search failure.
	OutcomeError
)

type OutsideEffectivePolicy

type OutsideEffectivePolicy uint8

OutsideEffectivePolicy controls queries outside inclusive effective dates.

const (
	// OutsideClosed treats dates outside the effective range as closed.
	OutsideClosed OutsideEffectivePolicy = iota
	// OutsideError rejects queries outside the effective range.
	OutsideError
)

type OverlapPolicy

type OverlapPolicy uint8

OverlapPolicy makes normalization of overlapping or adjacent input explicit.

const (
	// RejectOverlap rejects overlapping ranges but permits adjacency.
	RejectOverlap OverlapPolicy = iota
	// RejectOverlapAndAdjacent rejects both overlap and adjacency.
	RejectOverlapAndAdjacent
	// MergeOverlap merges overlap but preserves adjacent ranges.
	MergeOverlap
	// MergeAdjacent merges both overlapping and adjacent ranges.
	MergeAdjacent
)

type Range

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

Range is a start-inclusive, end-exclusive local-time interval. If End is earlier than Start, the interval is overnight and belongs to its start date.

func NewRange

func NewRange(start, end LocalTime) (Range, error)

NewRange creates a non-empty local-time range.

func (Range) End

func (r Range) End() LocalTime

End returns the exclusive endpoint.

func (Range) Overnight

func (r Range) Overnight() bool

Overnight reports whether the range ends on the following civil date.

func (Range) Start

func (r Range) Start() LocalTime

Start returns the inclusive endpoint.

type ResolvedLocal

type ResolvedLocal struct {
	Instant time.Time
	Kind    LocalKind
}

ResolvedLocal records the instant and DST classification selected by policy.

type RuleKind

type RuleKind uint8

RuleKind identifies the broad rule source used by a query.

const (
	// RuleNone means no schedule rule supplied availability.
	RuleNone RuleKind = iota
	// RuleWeekly means the current date's weekly rule supplied availability.
	RuleWeekly
	// RuleWeeklySpill means the preceding date's overnight rule supplied it.
	RuleWeeklySpill
	// RuleException means a dated exception supplied the final result.
	RuleException
	// RuleComposition means schedule algebra supplied the final result.
	RuleComposition
	// RuleOutsideEffective means the queried date is outside configured dates.
	RuleOutsideEffective
)

type Schedule

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

Schedule is an immutable availability value. Its zero value is closed and carries no timezone; it never means always open.

func NewSchedule

func NewSchedule(config Config) (Schedule, error)

NewSchedule validates and copies all caller-owned input.

func ParseJSON

func ParseJSON(data []byte) (Schedule, error)

ParseJSON strictly parses a bounded canonical schedule document.

func (Schedule) CanonicalJSON

func (s Schedule) CanonicalJSON() ([]byte, error)

CanonicalJSON returns stable, compact, versioned JSON.

func (Schedule) Compare

func (s Schedule) Compare(other Schedule) (int, error)

Compare returns -1, 0, or 1 according to the schedules' canonical byte ordering. It includes provenance and composition shape, like Equal.

func (Schedule) EffectiveInstantRanges

func (s Schedule) EffectiveInstantRanges(start, end time.Time) ([]InstantRange, error)

EffectiveInstantRanges returns clipped absolute availability within a bounded interval of at most 366 elapsed days.

func (Schedule) EffectiveRanges

func (s Schedule) EffectiveRanges(date Date) ([]DailyRange, error)

EffectiveRanges returns normalized availability fragments for one civil date.

func (Schedule) Equal

func (s Schedule) Equal(other Schedule) bool

Equal reports canonical equality, including provenance and composition shape.

func (Schedule) Hash

func (s Schedule) Hash() [sha256.Size]byte

Hash returns the SHA-256 hash of the canonical schedule encoding.

func (Schedule) HumanSummary

func (s Schedule) HumanSummary() (string, error)

HumanSummary returns deterministic presentation text that is not a wire encoding and cannot be parsed by UnmarshalText. It excludes labels and exception provenance, reporting only the number of dated exceptions.

func (Schedule) Intersection

func (s Schedule) Intersection(other Schedule) (Schedule, error)

Intersection returns a schedule open only when both operands are open.

func (Schedule) IsOpen

func (s Schedule) IsOpen(instant time.Time) (Availability, error)

IsOpen evaluates an absolute instant in the schedule's explicit timezone.

func (Schedule) IsOpenLocal

func (s Schedule) IsOpenLocal(date Date, localTime LocalTime, policy LocalResolutionPolicy) (Availability, error)

IsOpenLocal resolves a civil date and wall-clock time under the explicit DST policy, then evaluates the selected instant in the schedule timezone.

func (Schedule) IsOpenNow

func (s Schedule) IsOpenNow(clock Clock) (Availability, error)

IsOpenNow evaluates an injected clock's current instant.

func (Schedule) MarshalJSON

func (s Schedule) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler with the canonical encoding.

func (Schedule) MarshalText

func (s Schedule) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler using canonical JSON text.

func (Schedule) Metadata

func (s Schedule) Metadata() Metadata

Metadata returns a detached copy of schedule provenance.

func (Schedule) NextClosing

func (s Schedule) NextClosing(instant time.Time, horizon time.Duration) (Transition, error)

NextClosing finds the first closing boundary strictly after instant.

func (Schedule) NextOpening

func (s Schedule) NextOpening(instant time.Time, horizon time.Duration) (Transition, error)

NextOpening finds the first opening boundary strictly after instant.

func (Schedule) NextTransition

func (s Schedule) NextTransition(instant time.Time, horizon time.Duration) (Transition, error)

NextTransition finds the first availability boundary strictly after instant. The horizon must be positive and no greater than 366 elapsed days.

func (Schedule) ObserveIsOpen

func (s Schedule) ObserveIsOpen(instant time.Time, elapsedClock ElapsedClock, observer Observer) (Availability, error)

ObserveIsOpen runs IsOpen and reports bounded operational data. A nil clock disables elapsed measurement and reports a zero duration.

func (Schedule) ObserveNextTransition

func (s Schedule) ObserveNextTransition(instant time.Time, horizon time.Duration, elapsedClock ElapsedClock, observer Observer) (Transition, error)

ObserveNextTransition runs a bounded transition search and reports its outcome. A nil clock disables elapsed measurement and reports a zero duration.

func (Schedule) OpenDuration

func (s Schedule) OpenDuration(start, end time.Time) (time.Duration, error)

OpenDuration returns elapsed open time within a bounded absolute interval.

func (Schedule) Overlay

func (s Schedule) Overlay(other Schedule) (Schedule, error)

Overlay returns a schedule where explicit right-hand rules override left-hand availability and inherited right-hand rules leave it unchanged.

func (Schedule) PreviousTransition

func (s Schedule) PreviousTransition(instant time.Time, horizon time.Duration) (Transition, error)

PreviousTransition finds the nearest availability boundary strictly before instant within a positive horizon of at most 366 elapsed days.

func (Schedule) Ranges

func (s Schedule) Ranges(date Date) (DayResult, error)

Ranges resolves the effective weekly rule for date. Missing and inherited weekly rules are closed because there is no lower-precedence source.

func (Schedule) ResolveLocal

func (s Schedule) ResolveLocal(date Date, localTime LocalTime, policy LocalResolutionPolicy) (ResolvedLocal, error)

ResolveLocal converts a civil date and wall-clock time in the schedule zone. Gaps and folds are never resolved without the caller-selected policy.

func (Schedule) Revision

func (s Schedule) Revision() string

Revision returns the opaque bounded revision identifier.

func (*Schedule) Scan

func (s *Schedule) Scan(source any) error

Scan implements sql.Scanner for JSON/JSONB bytes, strings, and NULL. NULL produces the fail-closed zero schedule.

func (Schedule) SemanticallyEqual

func (s Schedule) SemanticallyEqual(other Schedule) bool

SemanticallyEqual compares interval semantics while ignoring metadata only.

func (Schedule) String

func (s Schedule) String() string

String returns canonical JSON or a bounded error marker.

func (Schedule) Subtract

func (s Schedule) Subtract(other Schedule) (Schedule, error)

Subtract returns a schedule open when s is open and other is closed.

func (Schedule) Timezone

func (s Schedule) Timezone() string

Timezone returns the explicit IANA timezone identity, or empty for zero value.

func (Schedule) Union

func (s Schedule) Union(other Schedule) (Schedule, error)

Union returns a schedule open whenever either operand is open.

func (*Schedule) UnmarshalJSON

func (s *Schedule) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler using the strict parser.

func (*Schedule) UnmarshalText

func (s *Schedule) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler using the strict parser.

func (Schedule) Value

func (s Schedule) Value() (driver.Value, error)

Value implements driver.Valuer using canonical JSON suitable for JSONB.

type Transition

type Transition struct {
	Instant     time.Time
	Kind        TransitionKind
	Explanation Explanation
}

Transition is an explained availability boundary.

type TransitionKind

type TransitionKind uint8

TransitionKind identifies an opening or closing boundary.

const (
	// TransitionOpen identifies a boundary whose following instant is open.
	TransitionOpen TransitionKind = iota
	// TransitionClose identifies a boundary whose following instant is closed.
	TransitionClose
)

Directories

Path Synopsis
adapters
calendar
Package openinghourscalendar adapts calendar civil dates and bounded business-calendar holidays to opening-hours values.
Package openinghourscalendar adapts calendar civil dates and bounded business-calendar holidays to opening-hours values.
config
Package openinghoursconfig adapts canonical schedule documents from configuration sources while leaving environment and file ownership to the caller.
Package openinghoursconfig adapts canonical schedule documents from configuration sources while leaving environment and file ownership to the caller.
temporal
Package openinghourstemporal provides lossless adapters for temporal/timeofday values.
Package openinghourstemporal provides lossless adapters for temporal/timeofday values.
validation
Package openinghoursvalidation adapts schedule validation to the shared validation contract.
Package openinghoursvalidation adapts schedule validation to the shared validation contract.
wire
Package openinghourswire adapts schedules to byte-oriented wire registries.
Package openinghourswire adapts schedules to byte-oriented wire registries.
Package compile provides an immutable prepared schedule handle for repeated queries.
Package compile provides an immutable prepared schedule handle for repeated queries.
Package encoding exposes the canonical schedule wire contract without shadowing human-readable formatting concerns in the root package.
Package encoding exposes the canonical schedule wire contract without shadowing human-readable formatting concerns in the root package.
Package openinghourscalendar is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/calendar.
Package openinghourscalendar is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/calendar.
Package openinghoursconfig is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/config.
Package openinghoursconfig is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/config.
Package openinghourstemporal is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/temporal.
Package openinghourstemporal is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/temporal.
Package openinghourstest provides panic-on-error builders for static tests.
Package openinghourstest provides panic-on-error builders for static tests.
Package openinghoursvalidation is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/validation.
Package openinghoursvalidation is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/validation.
Package openinghourswire is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/wire.
Package openinghourswire is the compatibility path for github.com/faustbrian/go-opening-hours/adapters/wire.
Package postgres provides nullable JSONB persistence values.
Package postgres provides nullable JSONB persistence values.

Jump to

Keyboard shortcuts

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