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

Bugfix: Correct calendar week date calculation logic #43

Merged
merged 5 commits into from
Jan 17, 2025

Conversation

christoph-teichmeister
Copy link
Contributor

Fixes a bug in get_start_and_end_date_from_calendar_week where the first calendar week was incorrectly determined. Adjusted the logic to compute the correct week start date based on ISO week rules. Added comprehensive test cases to ensure proper functionality for edge cases.

Bärbel and I stumbled upon this 🫠🫠🫠

Fixes a bug in `get_start_and_end_date_from_calendar_week` where the first calendar week was incorrectly determined. Adjusted the logic to compute the correct week start date based on ISO week rules. Added comprehensive test cases to ensure proper functionality for edge cases.
Update version number in the ambient_toolbox package. This prepares the package for a new release with potential fixes or enhancements.
Replace hardcoded integer comparison with `calendar.Day.THURSDAY` for clarity and maintainability. This ensures proper handling of weekdays when calculating the nearest Monday for the given year.
Replaced the `calendar.Day.THURSDAY` enum reference with a more explicit constant value (`3`). This improves readability and eliminates dependency on the `calendar` module's enum for this specific use case.
ambient_toolbox/utils/date.py Outdated Show resolved Hide resolved
tests/test_utils_date.py Show resolved Hide resolved
Replaced the hardcoded magic number for Thursday with the `calendar.THURSDAY` constant to improve code readability and maintainability. This change ensures better clarity and alignment with Python's standard library practices.
@GitRon GitRon merged commit dcb0086 into master Jan 17, 2025
16 checks passed
@GitRon GitRon deleted the bugfix/fix-calendar-week-bug branch January 17, 2025 11:55
@christoph-teichmeister christoph-teichmeister removed their assignment Jan 22, 2025
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