Skip to content

Test: Add unit tests for human-readable date/time formatters - #4388

Merged
Fokko merged 2 commits into
apache:mainfrom
prabhleen2317:test-datetime-human-formatters
Nov 17, 2026
Merged

Fokko merged 2 commits into
apache:mainfrom
prabhleen2317:test-datetime-human-formatters

Conversation

@prabhleen2317

Copy link
Copy Markdown
Contributor

Summary

  • Add unit tests for the previously untested to_human_* date/time
    formatters in pyiceberg/utils/datetime.py
    (to_human_year/month/day/hour/time/timestamp/timestamptz)
  • Also cover micros_to_days and days_to_date
  • Pure input→output functions; tests use explicit expected values

Closes #4387

Test plan

  • make test PYTEST_ARGS="-k datetime" — all pass
  • make lint — clean (ruff, format, mypy, codespell)

Cover the previously untested to_human_* formatters in
pyiceberg/utils/datetime.py, plus micros_to_days and days_to_date.
Comment thread tests/utils/test_datetime.py Resolved
Comment thread tests/utils/test_datetime.py Resolved
Cover the Julian/Gregorian boundary (proleptic Gregorian, per spec) in
days_to_date, and negative pre-1970 inputs in the human-readable
timestamp formatters, per review feedback.
@prabhleen2317

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @ebyhr! Addressed both in 4047bb6:

  • Added the 1582 Julian/Gregorian boundary cases (1582-10-04/05/15) in test_days_to_date, with a comment noting the proleptic Gregorian behavior per the Iceberg spec.
  • Added pre-epoch (-1, …) cases in both test_to_human_timestamp and test_to_human_timestamptz.

@prabhleen2317

Copy link
Copy Markdown
Contributor Author

Hello @ebyhr , @Fokko and @rambleraptor could you please have a look towards the changes made !

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for formalizing the behavior in tests @prabhleen2317, and thanks @ebyhr for the review 🚀

@Fokko
Fokko added this pull request to the merge queue Nov 17, 2026
Merged via the queue into apache:main with commit a385453 Nov 17, 2026
20 checks passed
@prabhleen2317

Copy link
Copy Markdown
Contributor Author

Thank you so much @Fokko and @ebyhr for the thorough review, helpful suggestions, and for getting this merged! Looking forward to contributing more :)

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.

Missing unit tests for human-readable date/time formatters in utils/datetime.py

3 participants