@@ -567,21 +567,6 @@ def _parsed_string_to_bounds(self, reso: Resolution, parsed: datetime):
567
567
-------
568
568
lower, upper: pd.Timestamp
569
569
"""
570
- assert isinstance (reso , Resolution ), (type (reso ), reso )
571
- valid_resos = {
572
- "year" ,
573
- "month" ,
574
- "quarter" ,
575
- "day" ,
576
- "hour" ,
577
- "minute" ,
578
- "second" ,
579
- "millisecond" ,
580
- "microsecond" ,
581
- }
582
- if reso .attrname not in valid_resos :
583
- raise KeyError
584
-
585
570
grp = reso .freq_group
586
571
per = Period (parsed , freq = grp .value )
587
572
start , end = per .start_time , per .end_time
@@ -590,17 +575,17 @@ def _parsed_string_to_bounds(self, reso: Resolution, parsed: datetime):
590
575
# If an incoming date string contained a UTC offset, need to localize
591
576
# the parsed date to this offset first before aligning with the index's
592
577
# timezone
578
+ start = start .tz_localize (parsed .tzinfo )
579
+ end = end .tz_localize (parsed .tzinfo )
580
+
593
581
if parsed .tzinfo is not None :
594
582
if self .tz is None :
595
583
raise ValueError (
596
584
"The index must be timezone aware when indexing "
597
585
"with a date string with a UTC offset"
598
586
)
599
- start = start .tz_localize (parsed .tzinfo ).tz_convert (self .tz )
600
- end = end .tz_localize (parsed .tzinfo ).tz_convert (self .tz )
601
- elif self .tz is not None :
602
- start = start .tz_localize (self .tz )
603
- end = end .tz_localize (self .tz )
587
+ start = self ._maybe_cast_for_get_loc (start )
588
+ end = self ._maybe_cast_for_get_loc (end )
604
589
return start , end
605
590
606
591
def _can_partial_date_slice (self , reso : Resolution ) -> bool :
0 commit comments