Repository navigation
fix(holidays): read stateCode like the other state utils, and follow the official texts on the open holiday questions - #603
Conversation
… non-state
getHolidays, isHoliday, isBusinessDay, addBusinessDays, subBusinessDays and
differenceInBusinessDays read stateCode through readHolidayStateCode: letter case and
surrounding whitespace are ignored, so "sp" now lists the São Paulo holidays instead of
silently dropping them. Only an omitted (undefined) stateCode means national holidays only;
any other value that is not a state code ("XX", "", a prototype-chain key, a non-string) is
rejected the way each util already rejects bad input: [] from getHolidays, false from
isHoliday and isBusinessDay, null from the business day walks. Return types are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RLkm9YrtAifc6XCLFVEsdH
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
Tree-shaking report✅ No size regression. 7 grew out of 194 exports.
What changed (7)
All exports (194)
How this is measuredEvery export is imported alone into an esbuild consumer bundle (minified, tree-shaken) built from the head and from the base of this pull request; the sizes are the resulting bundles, gzip is their gzipped size. 🔴 marks a regression: a pre-existing export that grew more than 20% and more than 256 B, or the bundle importing every pre-existing export growing more than 5%. 🟡 is growth under the threshold, 🟢 a decrease, ⚪ no change, 🆕 an export that does not exist on the base (never a regression), 🗑️ an export that was removed. An intentional increase is accepted with the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude/capitals-regions #603 +/- ##
===========================================================
Coverage ? 100.00%
===========================================================
Files ? 235
Lines ? 2418
Branches ? 720
===========================================================
Hits ? 2418
Misses ? 0
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…y questions - AP 25/07 (Dia de São Tiago) has no entry in any year: STF ADI 4820 struck Lei AP nº 1.696/2012 down (20/09/2018, trânsito 12/12/2018). - National: the other festas nacionais of Decreto nº 155-B/1890 and Decreto nº 3/1891 (24/02, 03/05, 13/05, 14/07, 12/10) up to 1930, and 03/05, 16/07 and 12/10 under Lei nº 108/1935 until Decreto-lei nº 486/1938. - The weekday general elections of 1955, 1958, 1990 and 1994, feriados nacionais under Lei nº 1.266/1950, art. 1º (1955 also Lei nº 2.550/1955). - GO: 26/07, 24/10 and 28/10 from 1986 (Lei GO nº 9.990/1986, then Lei GO nº 10.460/1988), and 02/11 as a GO holiday from 1986 to 2002. - AL 16/09 typed state from 2011, as the calendar decrees label it. - PE data magna on the first Sunday of March from 2010 to 2017 (Lei PE nº 13.835/2009), a new firstSundayOfMonth date rule. - SC: a Saturday date moves to the Sunday too (Decreto SC nº 1.460/2018), and 25/11/2004 keeps its transfer (ALESC compilation of Lei 10.306/1996). - RO 04/01 from 1983 (Decreto-Lei RO nº 39/1982). - Docs: SC law date, GO and RO decree moves, AC decrees 2024-2026, TRT-13 on PB 05/08, AL decree sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLkm9YrtAifc6XCLFVEsdH
What does this PR do?
Stacks on #601. The holiday and business day utils ignored a
stateCodethey did not know and fell back to the national holidays. The worst case was a lower case code:getHolidays({ year: 2024, stateCode: "sp" })silently left out every São Paulo holiday, andisBusinessDaythen counted 9 July as a business day in SP.getHolidays,isHoliday,isBusinessDay,addBusinessDays,subBusinessDaysanddifferenceInBusinessDaysnow readstateCodethrough one internal helper,readHolidayStateCode:stateCodeundefined"SP""sp"," SP "getStateCapital,getTimezoneByStateand the other state utils"XX","","__proto__"5,null,{})getHolidays, which returned the national holidaysA rejection uses what each util already returns for bad input (an invalid year, for instance):
[]fromgetHolidays,falsefromisHolidayandisBusinessDay, andnullfrom the three business day walks. No return type changes, socheck:apipasses. Rejecting a value that is not the code of a Brazilian state follows the stack's rule that rejecting what the official source says cannot exist is not a breaking change.The docs (both languages) and the JSDoc of the six utils say so, and note the 2.4.0 behaviour. This item came from the v3 tracking issue #602 and is fixed here instead of being deferred.
Holiday data, from the official texts (41290e7)
A comparison against the Python
holidayslibrary left 22 questions open. The primary texts for them were then collected (STF, Planalto, Câmara, and state legislatures, Casas Civis and official gazettes). Each change below cites its text insrc/get-holidays/constants.ts.optional2020–2023,statefrom 2024statefrom 2011firstSundayOfMonthdate rule)Documentation only:
Left out and documented, pending a text:
Not modelled, as before: the AC Friday rule, since the 2026 decree still leaves 17/11 in place.
Every change either rejects what an official text says cannot exist or accepts what one documents, so none is a breaking change;
check:apiholds.Checklist
docs/utilities.mdanddocs/pt-br/utilities.md.npm run checkpasses locally. These also pass: coverage (100%), Stryker on the changed files (100%), Deno, Bun,check:unused,check:duplicationandcheck:api(no breaking change against 2.4.0).npm run build:llms.Additional context
Tree-shaking: the six utils grow by 219 to 273 B each, which is the list of the 27 state codes they now check against. There is no size regression.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RLkm9YrtAifc6XCLFVEsdH