Avoid many replace calls in find_next_time_expression_time (#108273)

pull/104417/head^2
J. Nick Koston 2024-01-17 21:44:40 -10:00 committed by GitHub
parent b4b041d4bf
commit 52e90b32df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -393,7 +393,8 @@ def find_next_time_expression_time(
next_second = seconds[0]
result += dt.timedelta(minutes=1)
result = result.replace(second=next_second)
if result.second != next_second:
result = result.replace(second=next_second)
# Match next minute
next_minute = _lower_bound(minutes, result.minute)
@ -406,7 +407,8 @@ def find_next_time_expression_time(
next_minute = minutes[0]
result += dt.timedelta(hours=1)
result = result.replace(minute=next_minute)
if result.minute != next_minute:
result = result.replace(minute=next_minute)
# Match next hour
next_hour = _lower_bound(hours, result.hour)
@ -419,7 +421,8 @@ def find_next_time_expression_time(
next_hour = hours[0]
result += dt.timedelta(days=1)
result = result.replace(hour=next_hour)
if result.hour != next_hour:
result = result.replace(hour=next_hour)
if result.tzinfo in (None, UTC):
# Using UTC, no DST checking needed