Skip to content
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

Improve Thailand holidays #929

Merged
merged 57 commits into from
Feb 10, 2023
Merged

Improve Thailand holidays #929

merged 57 commits into from
Feb 10, 2023

Conversation

PPsyrius
Copy link
Collaborator

@PPsyrius PPsyrius commented Feb 4, 2023

A subclass of :py:class:HolidayBase representing public holidays in Thailand.
(Based on South Korean and Singaporean Implementation)

Limitations:

  • This is only 100% accurate for 1997-2023; any future dates are up to Royal Thai Government Gazette updates on a year-by-year basis.
  • Approx. date only goes as far back as 1941 (B.E. 2484) as the Thai calendar for B.E. 2483 as we only have nine months from switching New Year Date (April 1st to January 1st).
  • Thai Lunar Calendar Holidays only work from 1941 (B.E. 2484) onwards until 2057 (B.E. 2600) as we only have Thai year-type data for cross-checking until then
  • Royal Ploughing Ceremony Day is date is announced on an annual basis by the Court Astrologers, so this will need an annual update to the library here
  • This doesn't cover Thai regional public holidays yet, but this is for the future

References:

@KJhellico
Copy link
Collaborator

Great work!

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.

Here is 2 critical changes (special_holidays and redundant parenthesis in Wisakha Bucha code)

holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
test/countries/test_thailand.py Outdated Show resolved Hide resolved
test/countries/test_thailand.py Outdated Show resolved Hide resolved
PPsyrius and others added 4 commits February 4, 2023 18:08
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
Co-Authored-By: ~Jhellico <KJhellico@users.noreply.github.com>
Co-Authored-By: ~Jhellico <KJhellico@users.noreply.github.com>
@PPsyrius
Copy link
Collaborator Author

PPsyrius commented Feb 4, 2023

@KJhellico Thank you so much for the help :)

I've fixed all the mentioned errors and applied all other suggestions; feel free to let me know if you need anything else.

@KJhellico
Copy link
Collaborator

PR should be into beta branch. So you need to rebase your changes on beta. And fix code formatting (see CONTRIBUTING.rst). And extend tests to all new cases. :)

@PPsyrius PPsyrius changed the base branch from master to beta February 4, 2023 12:37
@PPsyrius
Copy link
Collaborator Author

PPsyrius commented Feb 5, 2023

@KJhellico The pre-commit checks from tox look good now, I hope :)

I'm willing to update this pull request so that the new changes would work perfectly with the i18n PoC (#827); just let me know if you plan to merge that change in first.

My other concern is the fact that ISO 3166-2:TH standards for provinces is pretty non-descriptive at best (a bit better than TIS 1099-2548 where the ISO codes were based on that has subdistrict code reuses) - so I'm thinking of using 3-letter acronyms from Royal Thai Government Announcement for Internal Indexing on 2021 (B.E. 2564) for future subdivision pull requests, if possible. Or ideally, finding ways to map both systems together so that input for either provincial code works.

Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
holidays/utils.py Outdated Show resolved Hide resolved
holidays/utils.py Outdated Show resolved Hide resolved
PPsyrius and others added 2 commits February 9, 2023 23:41
Co-Authored-By: ~Jhellico <KJhellico@users.noreply.github.com>
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.

Seems good

holidays/utils.py Show resolved Hide resolved
holidays/utils.py Outdated Show resolved Hide resolved
holidays/utils.py Outdated Show resolved Hide resolved
holidays/utils.py Show resolved Hide resolved
holidays/utils.py Outdated Show resolved Hide resolved
holidays/utils.py Outdated Show resolved Hide resolved
holidays/utils.py Outdated Show resolved Hide resolved
holidays/utils.py Show resolved Hide resolved
holidays/utils.py Show resolved Hide resolved
holidays/utils.py Show resolved Hide resolved
PPsyrius and others added 2 commits February 10, 2023 14:51
- Simplified __init__ section for Thailand's, removed for _ThaiLuniSolar
- Simplified _ThaiLuniSolar holiday codes
- _ThaiLuniSolar's comment are now docstrings
- Move all Thailand's holiday references to above limitations' section
- Remove Thailand's duplicate date checks (with TODO comments instead)
- Thailand's In Line comments are also moved to each holiday's header for better readability

Co-Authored-By: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
Co-Authored-By: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
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.

Looks good to me except a few minor issues.

Thanks for addressing all the comments!

holidays/utils.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
holidays/countries/thailand.py Show resolved Hide resolved
holidays/countries/thailand.py Outdated Show resolved Hide resolved
PPsyrius and others added 2 commits February 11, 2023 01:06
Co-Authored-By: Arkadii Yakovets <2201626+arkid15r@users.noreply.github.com>
holidays/utils.py Outdated Show resolved Hide resolved
@PPsyrius
Copy link
Collaborator Author

We failed coverall tests as the two extra cases added (Atthami Bucha, End of Buddhist Lent) got no active use cases.

Should we just comment them out for now or add tests for them somewhere?

@arkid15r
Copy link
Collaborator

We failed coverall tests as the two extra cases added (Atthami Bucha, End of Buddhist Lent) got no active use cases.

Should we just comment them out for now or add tests for them somewhere?

If you're comfortable with adding those - it would be just perfect! Otherwise I'd take a look into it early next week.

I'm going to merge this PR later today.

This PR has taken a huge amount of work. Thank you @PPsyrius, @KJhellico!

@arkid15r arkid15r added the ready for beta Ready to merge on beta branch label Feb 10, 2023
@PPsyrius
Copy link
Collaborator Author

PPsyrius commented Feb 10, 2023

I'll leave the issue of test cases for those two dates in your hands then - from a quick check, while Atthami Bucha (Buddha's Cremation Day) got no public holiday among mainland SEA countries in Sri Lanka; the End of Buddhist Lend (Ok Phansa in Laos and Boun Om Touk in Cambodia`) are still celebrated, even if they're yet to be implemented in this library at this point.

TYSM for all the help :)

@arkid15r arkid15r changed the title Thailand Calendar Improvements Improve Thailand holidays Feb 10, 2023
@arkid15r arkid15r merged commit c32369d into vacanza:beta Feb 10, 2023
@arkid15r arkid15r removed the ready for beta Ready to merge on beta branch label Feb 10, 2023
@PPsyrius PPsyrius deleted the thailand_improved branch February 16, 2023 14:31
This was referenced Feb 20, 2023
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.

4 participants