Skip to content

Conversation

@chetmancini
Copy link
Owner

Summary

This PR improves the dateutils library by addressing edge cases, adding comprehensive tests, and enhancing documentation based on a thorough code review.

Critical Fixes

  • ISO8601 fractional seconds truncation: Fractional seconds >6 digits are now explicitly truncated to microsecond precision with documentation
  • DST ambiguous time documentation: Added comprehensive warnings about fold attribute behavior to convert_timezone() and datetime_to_utc()
  • Invalid calendar date handling: Documented that parse_date() returns None for invalid dates like Feb 29 in non-leap years

New Edge Case Tests

Test Description
test_parse_iso8601_nanosecond_truncation Verifies microsecond precision limit
test_datetime_to_utc_dst_ambiguous_times Documents DST fall-back fold behavior
test_parse_date_invalid_calendar_dates Tests Feb 29 non-leap, April 31, etc.
test_add_business_days_negative_cross_year_with_holidays Cross-year boundary with holidays
test_get_week_number_jan1_in_previous_year_week ISO week edge cases (Jan 1 in week 52/53)
test_format_timezone_offset_dst_variance Verifies offset varies with DST
Nepal UTC+5:45 test 45-minute timezone offset support

Documentation Enhancements

  • Generator consumption warning: Made more prominent in workdays_between() and add_business_days() docstrings
  • LRU cache documentation: Added cache size (maxsize=32) and thread safety notes to get_us_federal_holidays()
  • pretty_date() approximations: Clarified that months=30 days, years=365 days
  • format_timezone_offset() DST note: Documents that returned offset varies for DST zones

Test plan

  • All 124 tests pass
  • 100% code coverage maintained
  • Linting passes (make lint)
  • Formatting passes (make format-check)
  • Type checking passes (make typecheck)

🤖 Generated with Claude Code

Critical fixes:
- Fix ISO8601 fractional seconds truncation (>6 digits now explicitly truncated)
- Add DST ambiguous time documentation to convert_timezone() and datetime_to_utc()
- Document parse_date() behavior for invalid calendar dates

New edge case tests:
- test_parse_iso8601_nanosecond_truncation: verify microsecond precision
- test_datetime_to_utc_dst_ambiguous_times: document fold attribute behavior
- test_parse_date_invalid_calendar_dates: Feb 29 non-leap, April 31, etc.
- test_add_business_days_negative_cross_year_with_holidays: year boundary
- test_get_week_number_jan1_in_previous_year_week: ISO week edge cases
- test_format_timezone_offset_dst_variance: DST offset changes
- Nepal UTC+5:45 minute-level offset test

Documentation enhancements:
- Add generator consumption warning to workdays_between() and add_business_days()
- Add LRU cache size (maxsize=32) and thread safety notes to get_us_federal_holidays()
- Add pretty_date() month/year approximation clarification
- Add format_timezone_offset() current-moment offset note

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Jan 29, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@chetmancini chetmancini merged commit b19b6eb into master Jan 29, 2026
6 checks passed
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