Skip to content

date/time conversion handles null-like objects#1005

Open
pawel-wolff wants to merge 1 commit into
developfrom
fix/datetime-convert
Open

date/time conversion handles null-like objects#1005
pawel-wolff wants to merge 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
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.53%. Comparing base (84aa271) to head (2e5d31f).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1005      +/-   ##
===========================================
+ Coverage    81.51%   81.53%   +0.02%     
===========================================
  Files          236      236              
  Lines        15472    15489      +17     
  Branches       756      756              
===========================================
+ Hits         12612    12629      +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.

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