+
Skip to content

Update Canada holidays: add historical holidays #2507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025

Conversation

PPsyrius
Copy link
Collaborator

@PPsyrius PPsyrius commented Apr 28, 2025

Proposed change

  • Fixes the 1935 Canadian Thanksgiving Day date.
  • Adds observances for Armistice Day (1921–1930).
  • Adds historical observances for Victoria Day (1901-1952).
  • Ensures all newly referenced sources are properly archived.
  • Refactors test case to meet newer release standards, updates snapshot.

While cleaning up outdated tiny.cc source link aliases as part of #2504, I've noticed that our source doesn't match other online sources. Additionally, "Armistice Day" was the combined precursor of both Thanksgiving and Remembrance Day for 1921-1930 so I've added them in too.

Type of change

  • New country/market holidays support (thank you!)
  • Supported country/market holidays update (calendar discrepancy fix, localization)
  • Existing code/documentation/test/process quality improvement (best practice, cleanup, refactoring, optimization)
  • Dependency update (version deprecation/pin/upgrade)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (a code change causing existing functionality to break)
  • New feature (new holidays functionality in general)

Checklist

Copy link
Contributor

coderabbitai bot commented Apr 28, 2025

Summary by CodeRabbit

  • New Features

    • Added historical "Victoria Day" (May 24) for 1950–1952 across all Canadian regions.
    • Introduced "Armistice Day" (1921–1930) as a recognized holiday with new translations in Arabic, French, and Thai.
  • Bug Fixes

    • Corrected Thanksgiving Day date for 1935 and improved historical accuracy for Thanksgiving and Armistice Day.
  • Documentation

    • Enhanced docstrings and comments for Canadian holiday logic and historical context.
  • Localization

    • Updated translation files for Canadian holidays in Arabic, English, French, and Thai, including new entries for "Armistice Day."
  • Tests

    • Improved and expanded test coverage for historical holidays and regional variations, with clearer variable naming.

Summary by CodeRabbit

  • New Features
    • Added "Armistice Day" as a recognized holiday in Canada for the years 1921–1930, with accurate historical dates.
  • Bug Fixes
    • Improved historical accuracy for the dates of Canadian Thanksgiving Day, including a correction for the year 1935.
  • Localization
    • Added translations for "Armistice Day" in Arabic, French, and Thai.
    • Updated translation files and metadata for multiple languages.
  • Tests
    • Enhanced tests to verify correct holiday names and dates for "Armistice Day" and "Thanksgiving Day" across different periods.

Walkthrough

This update refines the handling of Canadian Thanksgiving and Armistice Day, ensuring historical accuracy in both the holiday logic and test coverage. The _add_thanksgiving_day method in the Canada holiday provider now reflects the correct dates and names for Thanksgiving and Armistice Day between 1921 and 1957. Localization files for Arabic, English (Canada/US), French, and Thai were updated to add translations for "Armistice Day" and update metadata. The associated test suite was expanded to verify the correct application of these holidays and their names across relevant years and provinces. Additionally, Victoria Day logic was centralized into a new private method, and historical Victoria Day dates for 1950–1952 were added to snapshot data across all Canadian regions.

Changes

Files/Paths Change Summary
holidays/countries/canada.py Updated _add_thanksgiving_day logic and docstring for historical accuracy; added _add_victoria_day method; changed method signature to include return type annotation; centralized Victoria Day logic; added comments and formatting improvements.
tests/countries/test_canada.py Expanded tests for Thanksgiving and Armistice Day, distinguishing names and date ranges; refined Remembrance Day tests; renamed variables from province-based to subdivision-based; improved clarity and coverage.
holidays/locale/ar/LC_MESSAGES/CA.po Updated metadata and added Arabic translation for "Armistice Day".
holidays/locale/en_CA/LC_MESSAGES/CA.po
holidays/locale/en_US/LC_MESSAGES/CA.po
Updated metadata; added new (untranslated) entry for "Armistice Day" in en_CA, and "Armistice Day" entry in en_US.
holidays/locale/fr/LC_MESSAGES/CA.po Updated metadata and added French translation for "Armistice Day".
holidays/locale/th/LC_MESSAGES/CA.po Updated metadata and added Thai translation for "Armistice Day".
snapshots/countries/CA_*.json Added "Victoria Day" on May 24 for the years 1950, 1951, and 1952 across multiple Canadian provincial and territorial snapshot files.

Suggested reviewers

  • KJhellico

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c381f49 and e697d09.

📒 Files selected for processing (1)
  • tests/countries/test_canada.py (30 hunks)
🧰 Additional context used
🧠 Learnings (1)
tests/countries/test_canada.py (1)
Learnt from: PPsyrius
PR: vacanza/holidays#2416
File: tests/countries/test_turkmenistan.py:52-64
Timestamp: 2025-04-05T04:47:27.213Z
Learning: For holiday tests in the vacanza/holidays project, structure tests by individual holidays rather than by years. Each test method should focus on a specific holiday and test it across multiple years (from start_year through 2050) using helper methods like `assertHolidayName`. For fixed holidays, use generators like `(f"{year}-01-01" for year in range(1991, 2051))`. For movable holidays, specify individual dates for specific years followed by a range check.
🔇 Additional comments (5)
tests/countries/test_canada.py (5)

26-44: Well-structured test setup for subdivision handling.

The refactoring from province-based to subdivision-based references is a solid improvement that aligns with the holiday class structure in the main implementation.


125-135: Good conditional holiday assertions based on subdivision.

The logic correctly handles the observed behavior differences across provinces/territories for Canada Day, improving test precision.


209-255: Historical Victoria Day implementation is comprehensive.

The test now properly covers Victoria Day's fixed date (May 24) period from 1901-1952 before it changed to the current floating date rule. The observed dates testing for historical years (1903-1942) is a valuable addition.


297-357: Excellent historical Armistice/Thanksgiving Day implementation.

The test now correctly captures the historical evolution:

  1. "Armistice Day" from 1921-1930
  2. "Thanksgiving Day" from 1931 onward
  3. Fixed the 1935 date (Oct 24 instead of Oct 25)

This aligns perfectly with the PR objective of adding historical holidays and fixing date accuracy issues.


486-492: Good refactoring of province-specific holiday names.

Moving the holiday name mapping to a dictionary improves readability and maintainability.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Apr 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d46f3e1) to head (e697d09).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #2507   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          215       215           
  Lines        13600     13598    -2     
  Branches      1931      1924    -7     
=========================================
- Hits         13600     13598    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

KJhellico
KJhellico previously approved these changes Apr 28, 2025
Copy link
Collaborator

@KJhellico KJhellico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good research! Maybe better to move references to class docstring?

@KJhellico KJhellico changed the title Update Canada holidays: fixes 1935 Thanksgiving Day, adds 1921-1930 Armistice Day Update Canada holidays: fix 1935 Thanksgiving Day, add 1921-1930 Armistice Day Apr 28, 2025
@PPsyrius PPsyrius changed the title Update Canada holidays: fix 1935 Thanksgiving Day, add 1921-1930 Armistice Day Update Canada holidays: adds historical holidays Apr 29, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a602a7 and 6ea821a.

📒 Files selected for processing (16)
  • holidays/countries/canada.py (13 hunks)
  • snapshots/countries/CA_AB.json (3 hunks)
  • snapshots/countries/CA_BC.json (3 hunks)
  • snapshots/countries/CA_COMMON.json (3 hunks)
  • snapshots/countries/CA_MB.json (3 hunks)
  • snapshots/countries/CA_NB.json (3 hunks)
  • snapshots/countries/CA_NL.json (3 hunks)
  • snapshots/countries/CA_NS.json (3 hunks)
  • snapshots/countries/CA_NT.json (3 hunks)
  • snapshots/countries/CA_NU.json (3 hunks)
  • snapshots/countries/CA_ON.json (3 hunks)
  • snapshots/countries/CA_PE.json (3 hunks)
  • snapshots/countries/CA_QC.json (3 hunks)
  • snapshots/countries/CA_SK.json (3 hunks)
  • snapshots/countries/CA_YT.json (3 hunks)
  • tests/countries/test_canada.py (33 hunks)
🧰 Additional context used
🧠 Learnings (1)
tests/countries/test_canada.py (1)
Learnt from: PPsyrius
PR: vacanza/holidays#2416
File: tests/countries/test_turkmenistan.py:52-64
Timestamp: 2025-04-05T04:47:27.213Z
Learning: For holiday tests in the vacanza/holidays project, structure tests by individual holidays rather than by years. Each test method should focus on a specific holiday and test it across multiple years (from start_year through 2050) using helper methods like `assertHolidayName`. For fixed holidays, use generators like `(f"{year}-01-01" for year in range(1991, 2051))`. For movable holidays, specify individual dates for specific years followed by a range check.
🧬 Code Graph Analysis (1)
tests/countries/test_canada.py (2)
holidays/countries/canada.py (1)
  • Canada (30-506)
tests/common.py (5)
  • assertHolidayName (195-199)
  • assertNoNonObservedHoliday (248-250)
  • assertNoHoliday (244-246)
  • assertHoliday (150-152)
  • assertNoHolidayName (273-275)
⏰ Context from checks skipped due to timeout of 300000ms (1)
  • GitHub Check: Test build on windows-latest
🔇 Additional comments (42)
holidays/countries/canada.py (8)

44-47: Good addition of authoritative and archived sources.

These new references properly document the historical context for Remembrance Day, Thanksgiving Day, and Victoria Day. Using web archive links ensures long-term availability.


156-174: Well-implemented historical correction for Thanksgiving and Armistice Day.

The implementation accurately captures the historical relationship between Thanksgiving Day and Armistice Day. The method properly handles the special case of 1935 Thanksgiving, which occurred on October 24 due to a General Election, and correctly implements Armistice Day for 1921-1930. The detailed docstring provides excellent historical context.

The date change from October 25 to October 24 in 1935 is historically accurate according to the cited Canadian Encyclopedia reference.


175-188: Excellent refactoring of Victoria Day logic.

This new dedicated method centralizes all Victoria Day logic that was previously scattered across multiple methods. The implementation correctly handles the historical rules:

  • Before 1953: May 24 (with Sunday observance rules)
  • 1953 onwards: First Monday before May 24

The detailed docstring provides clear historical context.


118-118: Good refactoring to use centralized Victoria Day method.

This change replaces direct conditional implementation with the new centralized method.


194-194: Consistent implementation of Victoria Day across subdivisions.

Changed all direct handling of Victoria Day to use the new centralized method. This improves code maintainability and ensures consistent handling across all Canadian subdivisions.

Also applies to: 230-230, 255-255, 288-288, 349-349, 370-370, 404-404, 462-462, 479-479


137-141: Improved formatting of Boxing Day handling.

Added helpful comments and trailing commas that improve code readability.


144-148: Consistent formatting for Christmas Day handling.

Added helpful comments and trailing commas for consistent style.

Also applies to: 150-154


168-169: Fixed 1935 Thanksgiving Day date.

Corrected the 1935 Thanksgiving Day date from October 25 to October 24, which is historically accurate according to the Canadian Encyclopedia reference.

snapshots/countries/CA_AB.json (1)

6-6: Added missing Victoria Day entries for 1950-1952.

These additions correctly implement the Victoria Day holiday for years 1950-1952 based on the historical rule that Victoria Day was observed on May 24 prior to 1953. This change brings the snapshot in line with the corrected _add_victoria_day() implementation.

Also applies to: 18-18, 30-30

snapshots/countries/CA_YT.json (1)

5-5: Added missing Victoria Day entries for 1950-1952.

These additions correctly implement the Victoria Day holiday for years 1950-1952 based on the historical rule that Victoria Day was observed on May 24 prior to 1953. This change ensures consistency with the updated _add_victoria_day() implementation.

Also applies to: 17-17, 29-29

snapshots/countries/CA_BC.json (1)

5-5: Added missing Victoria Day entries for 1950-1952.

These additions correctly implement the Victoria Day holiday for years 1950-1952 based on the historical rule that Victoria Day was observed on May 24 prior to 1953. This ensures all provinces and territories have consistent historical holiday data.

Also applies to: 16-16, 27-27

snapshots/countries/CA_ON.json (1)

5-5: Approve snapshot additions for Victoria Day
The entries for "1950-05-24", "1951-05-24", and "1952-05-24" correctly reflect Victoria Day prior to the 1953 rule change. They are inserted in proper chronological order and align with the new private _add_victoria_day() logic.

Also applies to: 17-17, 29-29

snapshots/countries/CA_SK.json (1)

5-5: Approve snapshot additions for Victoria Day
The added "1950-05-24", "1951-05-24", and "1952-05-24" entries match the centralized Victoria Day rules and maintain correct ordering in the Saskatchewan snapshot.

Also applies to: 17-17, 29-29

snapshots/countries/CA_COMMON.json (1)

5-5: Approve snapshot additions for Victoria Day
Adding "1950-05-24", "1951-05-24", and "1952-05-24" in the common snapshot fills in the pre-1953 Victoria Day dates in line with the refactored logic. Order and consistency look good.

Also applies to: 16-16, 27-27

snapshots/countries/CA_PE.json (1)

5-5: Approve snapshot additions for Victoria Day
The Prince Edward Island snapshot now includes "1950-05-24", "1951-05-24", and "1952-05-24" for Victoria Day, correctly mirroring the new historical rule implementation.

Also applies to: 16-16, 27-27

snapshots/countries/CA_QC.json (3)

6-6: Approve missing Victoria Day for 1950.
Entry "1950-05-24": "Victoria Day" correctly reflects the pre-1953 rule.


19-19: Approve missing Victoria Day for 1951.
Entry "1951-05-24": "Victoria Day" is accurate and in line with the new _add_victoria_day() logic.


33-33: Approve missing Victoria Day for 1952.
Entry "1952-05-24": "Victoria Day" matches historical observance prior to the shift in 1953.

snapshots/countries/CA_NT.json (3)

5-5: Approve missing Victoria Day for 1950 (NT).
Snapshot now includes "1950-05-24": "Victoria Day", consistent with other provinces.


17-17: Approve missing Victoria Day for 1951 (NT).
Entry "1951-05-24": "Victoria Day" aligns with the shared pre-1953 rule.


29-29: Approve missing Victoria Day for 1952 (NT).
Entry "1952-05-24": "Victoria Day" correctly captures the historical date.

snapshots/countries/CA_NL.json (3)

6-6: Approve missing Victoria Day for 1950 (NL).
Snapshot now correctly lists "1950-05-24": "Victoria Day".


19-19: Approve missing Victoria Day for 1951 (NL).
Entry "1951-05-24": "Victoria Day" follows the unified logic.


32-32: Approve missing Victoria Day for 1952 (NL).
Adding "1952-05-24": "Victoria Day" is consistent with the new rule.

snapshots/countries/CA_NU.json (3)

5-5: Approve missing Victoria Day for 1950 (NU).
The snapshot entry "1950-05-24": "Victoria Day" is correct.


17-17: Approve missing Victoria Day for 1951 (NU).
Entry "1951-05-24": "Victoria Day" matches the centralized logic.


29-29: Approve missing Victoria Day for 1952 (NU).
Adding "1952-05-24": "Victoria Day" aligns with the historical observance.

snapshots/countries/CA_NB.json (3)

5-5: Good addition of missing Victoria Day for 1950.

This accurately adds Victoria Day on May 24, 1950, which was previously missing. This follows the historical fixed date rule before Victoria Day changed to a floating Monday in 1953.


16-16: Properly adds Victoria Day for 1951.

Adding Victoria Day on May 24, 1951 maintains historical accuracy for the period when Victoria Day was celebrated on a fixed date rather than the floating date system that started in 1953.


27-27: Correctly adds Victoria Day for 1952.

Including Victoria Day on May 24, 1952 completes the set of missing Victoria Day holidays for the years immediately preceding the 1953 change to a floating Monday celebration.

snapshots/countries/CA_MB.json (3)

5-5: Good addition of Victoria Day for 1950.

This properly adds the Victoria Day holiday for Manitoba on May 24, 1950, maintaining consistency with other Canadian provinces and historical accuracy.


17-17: Victoria Day for 1951 correctly added.

Adding Victoria Day for Manitoba on May 24, 1951 is historically accurate. This ensures Manitoba's holiday data is consistent with the fixed date observation of Victoria Day during this period.


29-29: Victoria Day for 1952 properly included.

The addition of Victoria Day on May 24, 1952 for Manitoba completes the set of missing holiday data for the years before Victoria Day switched to a floating date celebration.

snapshots/countries/CA_NS.json (3)

5-5: Victoria Day for 1950 properly added.

The addition of Victoria Day on May 24, 1950 for Nova Scotia aligns with the historical observance and ensures consistency with other provinces.


16-16: Victoria Day for 1951 correctly included.

Adding Victoria Day for May 24, 1951 in Nova Scotia's holiday data helps maintain historical accuracy for the fixed-date observance period.


27-27: Good addition of Victoria Day for 1952.

Including Victoria Day on May 24, 1952 for Nova Scotia completes the historical data for the years before the holiday switched to a floating Monday celebration in 1953.

tests/countries/test_canada.py (6)

38-56: Good variable name refactoring for clarity.

The change from prov/prov_hols to subdiv/subdiv_holidays provides more accurate terminology and better aligns with the Canada.subdivisions property. This improves code readability and maintainability.


223-264: Improved Victoria Day test coverage.

Adding explicit tests for observed Victoria Day instances and improving the structure of assertions strengthens the test suite. The addition of dts_obs with specific observed dates for Victoria Day is particularly valuable for ensuring the holiday behaves correctly when it falls on a Sunday.


309-369: Great historical accuracy improvement for Thanksgiving/Armistice Day.

This significant enhancement adds proper testing for two distinct holiday periods:

  1. "Armistice Day" from 1921-1930
  2. "Thanksgiving Day" from 1931 onward

The test also corrects a historical date for 1935 Thanksgiving (changing from October 25th to October 24th). This improves historical accuracy and provides better test coverage for this important Canadian holiday.


390-404: Improved Remembrance Day tests with better subdivision handling.

The updated test structure for Remembrance Day better handles subdivision-specific behavior, separating provinces that have observed date shifts from those that don't. This makes the tests more readable and maintainable.


824-830: Updated Queen's funeral test with new variable names.

Correctly modified the Queen's funeral test to use the new subdiv/subdiv_holidays variable names while maintaining the original test logic.


971-1005: Armistice Day properly reflected in localization tests.

The localization tests have been properly updated to include Armistice Day, ensuring that translations for this holiday are available in multiple languages. This is important for historical completeness.

Copy link
Collaborator

@KJhellico KJhellico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great refactoring!

PPsyrius and others added 2 commits April 29, 2025 19:29
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
Signed-off-by: Panpakorn Siripanich <19505219+PPsyrius@users.noreply.github.com>
Copy link

@PPsyrius PPsyrius requested a review from KJhellico April 29, 2025 15:15
@PPsyrius PPsyrius changed the title Update Canada holidays: adds historical holidays Update Canada holidays: add historical holidays Apr 29, 2025
Copy link
Collaborator

@KJhellico KJhellico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@arkid15r arkid15r added this pull request to the merge queue Apr 29, 2025
Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Merged via the queue into vacanza:dev with commit fd48972 Apr 29, 2025
33 checks passed
@PPsyrius PPsyrius deleted the canada_thanksgiving branch April 29, 2025 17:12
@arkid15r arkid15r mentioned this pull request May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载