|
49 | 49 | use_32bit_repr = is_platform_windows() or not IS64
|
50 | 50 |
|
51 | 51 |
|
52 |
| -def get_local_am_pm(): |
53 |
| - """Return the AM and PM strings returned by strftime in current locale""" |
54 |
| - am_local = time(1).strftime("%p") |
55 |
| - pm_local = time(13).strftime("%p") |
56 |
| - return am_local, pm_local |
57 |
| - |
58 |
| - |
59 | 52 | @pytest.fixture(params=["string", "pathlike", "buffer"])
|
60 | 53 | def filepath_or_buffer_id(request):
|
61 | 54 | """
|
@@ -3198,26 +3191,23 @@ def test_period(self):
|
3198 | 3191 | def test_period_custom(self):
|
3199 | 3192 | # GH46252
|
3200 | 3193 |
|
3201 |
| - # Get locale-specific reference |
3202 |
| - am_local, pm_local = get_local_am_pm() |
3203 |
| - |
3204 | 3194 | # 3 digits
|
3205 | 3195 | p = pd.period_range("2003-01-01 12:01:01.123", periods=2, freq="l")
|
3206 |
| - formatted = p.format(date_format="%y %I:%M:%S%p (ms=%l us=%u ns=%n)") |
3207 |
| - assert formatted[0] == f"03 12:01:01{pm_local} (ms=123 us=123000 ns=123000000)" |
3208 |
| - assert formatted[1] == f"03 12:01:01{pm_local} (ms=124 us=124000 ns=124000000)" |
| 3196 | + formatted = p.format(date_format="%y %I:%M:%S (ms=%l us=%u ns=%n)") |
| 3197 | + assert formatted[0] == "03 12:01:01 (ms=123 us=123000 ns=123000000)" |
| 3198 | + assert formatted[1] == "03 12:01:01 (ms=124 us=124000 ns=124000000)" |
3209 | 3199 |
|
3210 | 3200 | # 6 digits
|
3211 | 3201 | p = pd.period_range("2003-01-01 12:01:01.123456", periods=2, freq="u")
|
3212 |
| - formatted = p.format(date_format="%y %I:%M:%S%p (ms=%l us=%u ns=%n)") |
3213 |
| - assert formatted[0] == f"03 12:01:01{pm_local} (ms=123 us=123456 ns=123456000)" |
3214 |
| - assert formatted[1] == f"03 12:01:01{pm_local} (ms=123 us=123457 ns=123457000)" |
| 3202 | + formatted = p.format(date_format="%y %I:%M:%S (ms=%l us=%u ns=%n)") |
| 3203 | + assert formatted[0] == "03 12:01:01 (ms=123 us=123456 ns=123456000)" |
| 3204 | + assert formatted[1] == "03 12:01:01 (ms=123 us=123457 ns=123457000)" |
3215 | 3205 |
|
3216 | 3206 | # 9 digits
|
3217 | 3207 | p = pd.period_range("2003-01-01 12:01:01.123456789", periods=2, freq="n")
|
3218 |
| - formatted = p.format(date_format="%y %I:%M:%S%p (ms=%l us=%u ns=%n)") |
3219 |
| - assert formatted[0] == f"03 12:01:01{pm_local} (ms=123 us=123456 ns=123456789)" |
3220 |
| - assert formatted[1] == f"03 12:01:01{pm_local} (ms=123 us=123456 ns=123456790)" |
| 3208 | + formatted = p.format(date_format="%y %I:%M:%S (ms=%l us=%u ns=%n)") |
| 3209 | + assert formatted[0] == "03 12:01:01 (ms=123 us=123456 ns=123456789)" |
| 3210 | + assert formatted[1] == "03 12:01:01 (ms=123 us=123456 ns=123456790)" |
3221 | 3211 |
|
3222 | 3212 | def test_period_tz(self):
|
3223 | 3213 | """Test formatting periods created from a datetime with timezone."""
|
|
0 commit comments