Skip to content

Commit

Permalink
Improved test for small years
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed Apr 2, 2024
1 parent 084f124 commit b4983f8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pandas/tests/scalar/timestamp/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,14 @@ def test_repr_matches_pydatetime_tz_dateutil(self):
assert str(dt_datetime_us) == str(Timestamp(dt_datetime_us))

def test_timestamp_repr_strftime_small_year_date(self):
stamp = Timestamp("0020-01-01")
assert repr(stamp) == "Timestamp('20-01-01 00:00:00')"
stamp = Timestamp("0002-01-01")
assert repr(stamp) == "Timestamp('2-01-01 00:00:00')"

str_tmp, loc_dt_s = convert_strftime_format("%Y-%y", target="datetime")
assert stamp._fast_strftime(str_tmp, loc_dt_s) == "0020-20"
# Make sure we agree with datetime.strftime
assert datetime(2, 1, 1).strftime("%Y") == "0002"
assert stamp.strftime("%Y") == "0002"
str_tmp, loc_dt_s = convert_strftime_format("%Y", target="datetime")
assert stamp._fast_strftime(str_tmp, loc_dt_s) == "0002"

def test_timestamp_repr_strftime_negative_date(self):
stamp = Timestamp("-0020-01-01")
Expand Down

0 comments on commit b4983f8

Please sign in to comment.