+
Skip to content

Add Qatar holidays #2409

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 9 commits into from
Apr 5, 2025
Merged

Add Qatar holidays #2409

merged 9 commits into from
Apr 5, 2025

Conversation

Wasif-Shahzad
Copy link
Contributor

@Wasif-Shahzad Wasif-Shahzad commented Apr 3, 2025

Add Qatar Holidays

I've added Qatar holidays. It included Bank Holidays too. I've added l10n support in ar_QA and en_US as well.
Closes #1253.

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 3, 2025

Summary by CodeRabbit

  • New Features
    • Introduced support for Qatar with comprehensive holiday calculations covering public and bank holidays, including special holiday designations.
    • Added localized holiday names for Qatar in both Arabic and English.
  • Documentation
    • Updated the supported country list to include Qatar and its corresponding details.
  • Tests
    • Implemented tests to ensure accurate holiday computations and proper localization for Qatar.

Walkthrough

This update extends holiday management support to Qatar. The README now reflects Qatar’s inclusion with an updated country code count and detailed entry. A new module for Qatar is introduced, along with corresponding export adjustments in the package’s initializer and registry. Localization files for Arabic and English are added, and a comprehensive test suite for Qatar’s holiday logic has been implemented.

Changes

File(s) Change Summary
README.md Updated supported country codes count from 164 to 165; added Qatar entry with ISO code QA, languages ar_QA and en_US, and supported category BANK.
holidays/.../init.py, holidays/registry.py Added a new import statement in __init__.py (from .qatar import Qatar, QA, QAT) and registered Qatar in the countries registry with tuple ("Qatar", "QA", "QAT").
holidays/.../qatar.py Introduced new module implementing Qatar holiday logic, including classes Qatar, QA, QAT, QatarIslamicHolidays, and QatarStaticHolidays with methods to populate public and bank holidays.
holidays/.../QA.po (ar_QA), holidays/.../QA.po (en_US) Added new localization files for Qatar holidays: the Arabic file with metadata and holiday string keys, and the English file providing corresponding translations.
tests/.../test_qatar.py Added a new test suite to validate Qatar holiday calculations, including tests for holiday aliases, dates, and localized holiday names.

Assessment against linked issues

Objective Addressed Explanation
Add Qatar holidays (1253)
Update documentation for new country (1253)
Implement tests for Qatar holiday logic (1253)

📜 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 1fb23ab and 980a4ce.

📒 Files selected for processing (1)
  • holidays/countries/qatar.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
holidays/countries/qatar.py (1)
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2409
File: holidays/countries/qatar.py:27-46
Timestamp: 2025-04-03T16:58:27.175Z
Learning: In the holidays library, method names like `_add_holiday_2nd_tue_of_feb()` and `_add_holiday_1st_sun_of_mar()` use calendar constants internally through parent class implementations even when these constants don't appear directly in the file. Removing imports that seem unused based on a simple text search could break functionality.
🔇 Additional comments (5)
holidays/countries/qatar.py (5)

37-45: Well-structured class with comprehensive documentation.

The Qatar class properly inherits from the appropriate base classes and includes thorough documentation with relevant references. The addition of the weekend reference documentation is a good improvement based on previous feedback.


69-71: Weekend configuration properly handles historical change.

The implementation correctly accounts for Qatar's weekend change from Thursday-Friday to Friday-Saturday that occurred in August 2003. This follows the standard pattern used in the library for handling weekend transitions.


81-91: Islamic holidays implementation follows library patterns.

The implementation of Eid al-Fitr and Eid al-Adha follows the established patterns in the library. Each holiday includes multiple days and uses the translation function for proper localization.


110-159: Comprehensive date definitions for Islamic holidays.

The QatarIslamicHolidays class provides a thorough collection of specific dates for Eid al-Adha and Eid al-Fitr, with proper references. The date coverage from 2005 to 2025 is extensive and well-sourced.


161-172: Special holiday definition is well-structured.

The QatarStaticHolidays class correctly implements special holiday definitions with proper documentation and references. Currently it includes the New Year's Holiday for 2025.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
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: 4

🔭 Outside diff range comments (1)
holidays/locale/en_US/LC_MESSAGES/QA.po (1)

1-62: ⚠️ Potential issue

Future dates in PO file metadata need correction.

The localization file is well-structured with proper translations for all Qatar holidays. However, the creation and revision dates are set to April 2025, which is in the future.

Apply this change to correct the dates:

-"POT-Creation-Date: 2025-04-03 09:48+0500\n"
-"PO-Revision-Date: 2025-04-03 10:42+0500\n"
+"POT-Creation-Date: 2024-04-03 09:48+0500\n"
+"PO-Revision-Date: 2024-04-03 10:42+0500\n"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ee26941 and ba6e7ff.

📒 Files selected for processing (7)
  • README.md (2 hunks)
  • holidays/countries/__init__.py (1 hunks)
  • holidays/countries/qatar.py (1 hunks)
  • holidays/locale/ar_QA/LC_MESSAGES/QA.po (1 hunks)
  • holidays/locale/en_US/LC_MESSAGES/QA.po (1 hunks)
  • holidays/registry.py (1 hunks)
  • tests/countries/test_qatar.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
holidays/countries/__init__.py (1)
holidays/countries/qatar.py (3)
  • Qatar (48-104)
  • QA (107-108)
  • QAT (111-112)
tests/countries/test_qatar.py (1)
holidays/countries/qatar.py (3)
  • Qatar (48-104)
  • QA (107-108)
  • QAT (111-112)
🔇 Additional comments (22)
holidays/registry.py (1)

146-146: Good addition of Qatar to the COUNTRIES dictionary.

The Qatar entry follows the correct format and is properly positioned alphabetically within the dictionary. This seamless integration will allow users to access Qatar holidays using the standard country codes.

holidays/countries/__init__.py (1)

138-138: Import statement for Qatar properly integrated.

The import for the Qatar module and its associated classes is correctly placed in alphabetical order, consistent with the project's import structure pattern.

holidays/locale/en_US/LC_MESSAGES/QA.po (1)

30-62: Well-structured translations for Qatar holidays.

The translations are clear and comprehensive, covering all holidays implemented in the Qatar class. The formatting follows the standard PO file pattern, making it easy to maintain and extend.

README.md (2)

102-102: Correctly updated country code count.

The country count has been properly updated from 163 to 164 to reflect the addition of Qatar.


1005-1010: Qatar entry properly formatted in README table.

The Qatar entry includes all necessary information (country name, code, supported languages, categories) and follows the same formatting pattern as other countries. The default language is correctly set to Arabic (ar_QA) with English (en_US) as an additional supported language.

holidays/locale/ar_QA/LC_MESSAGES/QA.po (3)

15-28: PO file structure appears correct, but confirm empty msgstr fields

The PO file structure and metadata look good with proper language settings (ar_QA). However, all the translation strings (msgstr) are empty, which is unusual for a complete localization file.

In gettext localization, typically the msgid contains the source text and msgstr contains the translation. Here, Arabic text is already in msgid fields, suggesting a non-standard approach.

Are empty msgstr fields intentional for this project? Please check other localization files to confirm this pattern is consistent with the project's localization approach.


29-32: Format string interpolation for estimates

This correctly defines a format string for estimated holidays. The localization string includes the Arabic phrase for "estimated" that will be used when displaying estimated Islamic holiday dates.


34-60: Holiday translations look complete

All necessary Qatar holidays have been included with proper Arabic names:

  • National Sports Day
  • Qatar National Day
  • Eid al-Fitr
  • Eid al-Adha
  • New Year's Day
  • New Year's Holiday
  • March Bank Holiday
tests/countries/test_qatar.py (7)

47-73: Sports Day test is thorough and accurate

The test thoroughly verifies National Sports Day dates from 2012 to 2030, correctly falling on the second Tuesday of February each year. It also checks that the holiday doesn't exist before 2012.


74-78: National Day test is properly implemented

The test correctly verifies that Qatar National Day is celebrated on December 18th starting from 2007.


79-107: Eid al-Fitr test uses accurate dates

The test properly verifies Eid al-Fitr dates for multiple years (2018-2025), including the three-day duration of the holiday.


109-135: Eid al-Adha test uses accurate dates

The test properly verifies Eid al-Adha dates for multiple years (2018-2024), including the three-day duration of the holiday.


136-143: Bank holiday tests properly configured

The New Year's Day test correctly verifies the holiday exists for all years in bank holidays category only.


144-167: March Bank Holiday test is comprehensive

Test thoroughly verifies that March Bank Holiday falls on the first Sunday of March from 2010 onward. It correctly checks it's only in the bank category and doesn't exist in public holidays.


186-214: Localization tests are thorough

The tests properly verify both default Arabic (ar_QA) and English (en_US) translations of all holidays, ensuring the localization works correctly.

holidays/countries/qatar.py (7)

48-63: Class attributes are well-defined

The Qatar class is well-structured with appropriate attributes:

  • Correct country code "QA"
  • Default language set to Arabic (ar_QA)
  • Support for both Arabic and English
  • Weekend correctly defined as Friday and Saturday
  • Appropriate categories for both public and bank holidays
  • Start year set to 1971 (Qatar's independence)

64-76: Constructor properly initializes parent classes

The constructor properly initializes Islamic and Static holidays with appropriate parameters. The islamic_show_estimated parameter allows flexibility in displaying estimated dates.


77-97: Public holidays implementation looks correct

The implementation of public holidays follows best practices:

  • National Sports Day starts from 2012 (second Tuesday of February)
  • Qatar National Day starts from 2007 (December 18)
  • Islamic holidays (Eid al-Fitr and Eid al-Adha) are properly implemented with 3-day duration

98-105: Bank holidays correctly implemented

Bank holidays are properly implemented:

  • New Year's Day (January 1)
  • March Bank Holiday (first Sunday of March) starting from 2010

107-113: Country code aliases defined correctly

Country code aliases QA and QAT are defined correctly to allow for flexible usage of the Qatar holiday class.


115-164: Islamic holiday dates are comprehensive

The QatarIslamicHolidays class provides specific dates for Eid al-Fitr and Eid al-Adha from 2005 to 2025, which helps ensure accurate holiday calculations. The reference to timeanddate.com provides appropriate attribution.


166-177: Static holidays implementation with documentation

The QatarStaticHolidays class properly defines a special New Year's Holiday for 2025 with appropriate reference documentation.

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f55391b) to head (980a4ce).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #2409   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          209       210    +1     
  Lines        13301     13348   +47     
  Branches      1906      1909    +3     
=========================================
+ Hits         13301     13348   +47     

☔ 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 changed the title Add Qatar holidays with localization Add Qatar holidays Apr 3, 2025
KJhellico
KJhellico previously approved these changes Apr 4, 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.

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 👍

Thanks for taking care of this @Wasif-Shahzad

@arkid15r arkid15r enabled auto-merge April 4, 2025 19:52
Copy link
Collaborator

@PPsyrius PPsyrius left a comment

Choose a reason for hiding this comment

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

Sorry about the late change requests - but I just remembered about Qatar's weekend change when we were combing through them a while back.

Other than that, the implementation in this PR looks solid 👍

auto-merge was automatically disabled April 5, 2025 08:17

Head branch was pushed to by a user without write access

Copy link

sonarqubecloud bot commented Apr 5, 2025

Copy link
Collaborator

@PPsyrius PPsyrius left a comment

Choose a reason for hiding this comment

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

LGTM 🇶🇦

@PPsyrius PPsyrius enabled auto-merge April 5, 2025 08:25
@PPsyrius PPsyrius added this pull request to the merge queue Apr 5, 2025
Merged via the queue into vacanza:dev with commit 7bd3eb0 Apr 5, 2025
32 checks passed
This was referenced Apr 7, 2025
This was referenced Apr 8, 2025
@coderabbitai coderabbitai bot mentioned this pull request Apr 15, 2025
9 tasks
@coderabbitai coderabbitai bot mentioned this pull request May 3, 2025
9 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jul 9, 2025
9 tasks
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.

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