This commit is contained in:
itqop 2025-12-19 13:46:21 +03:00
parent f5d8b46e56
commit c1ec641ee0
1 changed files with 7 additions and 9 deletions

View File

@ -24,26 +24,25 @@ class TimeService:
def get_now(self) -> datetime:
"""
Get current datetime in configured timezone.
Get current datetime as naive UTC.
Returns:
Current datetime
Current datetime (naive UTC)
"""
return datetime.now(self.timezone)
return datetime.utcnow()
def combine_date_time(self, date: datetime, time_of_day: time) -> datetime:
"""
Combine date and time in configured timezone.
Combine date and time as naive datetime.
Args:
date: Date component
time_of_day: Time component
Returns:
Combined datetime
Combined naive datetime
"""
naive_dt = datetime.combine(date.date(), time_of_day)
return naive_dt.replace(tzinfo=self.timezone)
return datetime.combine(date.date(), time_of_day)
def calculate_next_run_time(
self,
@ -109,13 +108,12 @@ class TimeService:
Format next run datetime for display.
Args:
next_run: Next run datetime
next_run: Next run datetime (naive UTC)
Returns:
Formatted string
"""
now = self.get_now()
delta = next_run - now
# If it's today
if next_run.date() == now.date():