Skip to content

date/time conversion handles null-like objects#1005

Merged
sandorkertesz merged 1 commit into
developfrom
fix/datetime-convert
May 27, 2026
Merged

date/time conversion handles null-like objects#1005
sandorkertesz merged 1 commit into
developfrom
fix/datetime-convert

Conversation

@pawel-wolff

Copy link
Copy Markdown
Contributor

Description

This is a follow-up of the PR #999. It provides more robust checks for null-like values in the context of convertion into a data/time object.

Null-like values are:

  • None
  • NaN
  • numpy NaT, i.e. numpy.datetime64('NaT') and numpy.timedelta64('NaT')
  • pandas.NaT

Now, the following to date/time conversion routines are checking for a null-like value and return None on a null-like input:

  • to_datetime()
  • to_time()
  • to_timedelta()

Additionally, the routines expecting numpy-type input, i.e.

  • numpy_timedelta_to_timedelta()
  • numpy_datetime_to_datetime()
    check for numpy NaT. Note that without such check, the conversion .astype(int) would produce a meaningless int, out of range for datetime.datetime.fromtimestamp() (see
    def numpy_datetime_to_datetime(dt):
    ).

Tests covering all the above changes have been added.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@pawel-wolff pawel-wolff requested a review from sandorkertesz May 26, 2026 08:04
@codecov-commenter

codecov-commenter commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.56%. Comparing base (1512d85) to head (f135d3b).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1005      +/-   ##
===========================================
+ Coverage    81.54%   81.56%   +0.02%     
===========================================
  Files          236      236              
  Lines        15493    15510      +17     
  Branches       756      756              
===========================================
+ Hits         12633    12650      +17     
  Misses        2634     2634              
  Partials       226      226              

☔ 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.

@pawel-wolff pawel-wolff force-pushed the fix/datetime-convert branch from 2e5d31f to f135d3b Compare May 27, 2026 08:56
@sandorkertesz sandorkertesz merged commit e015000 into develop May 27, 2026
148 checks passed
@sandorkertesz sandorkertesz deleted the fix/datetime-convert branch May 27, 2026 14:02
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.

3 participants