Repository navigation
Only check the date part of a reference date for a four-digit year - #11997
Open
1AbdullahButt wants to merge 1 commit into
Open
1AbdullahButt wants to merge 1 commit into
1AbdullahButt wants to merge 1 commit into
Conversation
_ensure_padded_year skipped zero-padding whenever the reference date held
four consecutive digits anywhere, so fractional seconds in the time part
("1-1-1 00:00:00.000000") or a "+0000" offset counted as a year. The
unpadded date then reached pandas, which reads "1-1-1" as 2001-01-01, and
decoding with the default use_cftime=None shifted every date by 2000
years.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1AbdullahButt
force-pushed
the
fix-padded-year-fractional-seconds
branch
from
December 5, 2026 22:43
067c708 to
c8ad7ea
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I noticed that
_ensure_padded_yearchecks the entire reference date for four consecutive digits, including the time part. This means that fractional seconds or UTC offsets can cause it to skip padding the year, resulting in an incorrect date.For example:
Using
use_cftime=Truegives the correct result, so the decoded date can differ depending on which decoding path is used. There is also no warning when this happens.I've changed the check to exclude the time part of the reference date. Dates that already contain a four-digit year, such as
1-1-1970,19700101orJan 1 1970, are unaffected.Testing
I extended
test_decode_ambiguous_time_warnsto cover reference dates with fractional seconds. Three cases fail on main, and all 18 pass with this change.I also ran the full
test_coding_times.pysuite:Checklist
whats-new.rstAI Disclosure
I used Claude Code to assist with the implementation and reviewed the changes and test results myself.
Tools: Claude Code
🤖 Generated with Claude Code