@@ -1740,3 +1740,23 @@ def test_date_range_negative_freq_year_end_inbounds(self, unit):
1740
1740
freq = "-1YE" ,
1741
1741
)
1742
1742
tm .assert_index_equal (rng , exp )
1743
+
1744
+ def test_date_range_tzaware_endpoints_accept_ambiguous (self ):
1745
+ # With tz-aware endpoints and a calendar offset (MS),
1746
+ # date_range should accept `ambiguous=True` and produce
1747
+ # the same result as passing tz explicitly with naive endpoints.
1748
+ start = Timestamp ("1916-08-01" , tz = "Europe/Oslo" )
1749
+ end = Timestamp ("1916-12-01" , tz = "Europe/Oslo" )
1750
+ res = date_range (start , end , freq = "MS" , ambiguous = True )
1751
+ exp = date_range (
1752
+ "1916-08-01" , "1916-12-01" , freq = "MS" , tz = "Europe/Oslo" , ambiguous = True
1753
+ )
1754
+ tm .assert_index_equal (res , exp )
1755
+
1756
+ def test_date_range_tzaware_endpoints_raise_ambiguous_raises_by_default (self ):
1757
+ # By default (`ambiguous="raise"`), an ambiguous DST transition
1758
+ # should raise instead of guessing.
1759
+ start = Timestamp ("1916-08-01" , tz = "Europe/Oslo" )
1760
+ end = Timestamp ("1916-12-01" , tz = "Europe/Oslo" )
1761
+ with pytest .raises (ValueError , match = "Cannot infer dst time" ):
1762
+ date_range (start , end , freq = "MS" )
0 commit comments