Skip to content

Add external holiday data provider support via holidays.provider#743

Draft
Copilot wants to merge 5 commits intodevelopfrom
copilot/analyze-holiday-data-usage
Draft

Add external holiday data provider support via holidays.provider#743
Copilot wants to merge 5 commits intodevelopfrom
copilot/analyze-holiday-data-usage

Conversation

Copy link

Copilot AI commented Mar 1, 2026

Holiday data is currently only readable from the config file. This adds an encapsulated API hook so an external tool can supply holiday data instead, enabling dynamic/third-party holiday sources.

Changes

src/data.cpp

  • getHolidayEntriesFromProvider(provider, range) — new static helper; invokes the configured tool as <tool> YYYY-MM-DD YYYY-MM-DD, parses JSON Lines output into (Datetime, name) pairs; malformed lines are silently skipped
  • getHolidays(const Rules&, const Range&) — new range-aware overload; delegates to the provider when configured, falls back to config-file data otherwise
  • getAllExclusions() — updated to call the range-aware getHolidays so provider holidays feed into the gaps/exclusions engine
  • createHolidayMap() — updated to use the provider when holidays.provider is set
  • getHolidays(rules) (no-range) — hardened to skip the holidays.provider key and catch date-parse errors from unexpected config entries

src/timew.h

  • Declares the new getHolidays(const Rules&, const Range&) overload

test/holidays.t (new)

  • Integration tests covering: provider output in summary, provider overrides config holidays, config holidays work without a provider, date range passed as CLI args, malformed JSON lines skipped

Usage

# timewarrior.cfg
holidays.provider = /path/to/my-holiday-tool

The tool is invoked as:

/path/to/my-holiday-tool 2025-01-01 2025-12-31

Each line of output must be a JSON object:

{"date":"2025-01-01","name":"New Year's Day"}

When holidays.provider is set, config-file holiday entries (holidays.<locale>.<date>) are ignored entirely.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits March 1, 2026 19:23
Co-authored-by: lauft <8539295+lauft@users.noreply.github.com>
- Move createHolidayMap() from CmdChart.cpp to data.cpp
- Move renderHolidays() free function from CmdSummary.cpp to data.cpp
- Declare both in timew.h alongside existing getHolidays()
- Have Chart::renderHolidays() delegate to the shared free function
- Remove cross-file forward declaration from CmdSummary.cpp
- Remove duplicate renderHolidays() from CmdSummary.cpp
- Remove createHolidayMap() definition from CmdChart.cpp
- Add build/ to .gitignore

Co-authored-by: lauft <8539295+lauft@users.noreply.github.com>
Co-authored-by: lauft <8539295+lauft@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze holiday data usage in Timewarrior Encapsulate holiday data retrieval and rendering in internal API Mar 1, 2026
Copilot finished work on behalf of lauft March 1, 2026 19:31
Co-authored-by: lauft <8539295+lauft@users.noreply.github.com>
Copilot AI changed the title Encapsulate holiday data retrieval and rendering in internal API Add external holiday data provider support via holidays.provider Mar 1, 2026
Copilot finished work on behalf of lauft March 1, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants