2023-10-18 14:00:28 +00:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
import pytz
|
|
|
|
|
|
|
|
|
|
|
|
def seconds_until(hours, minutes):
|
2024-07-17 11:47:26 +00:00
|
|
|
eastern_timezone = pytz.timezone("US/Eastern")
|
2023-10-18 14:00:28 +00:00
|
|
|
|
|
|
|
now = datetime.datetime.now(eastern_timezone)
|
|
|
|
|
|
|
|
# Create a datetime object for the given time in the Eastern Timezone
|
|
|
|
given_time = datetime.time(hours, minutes)
|
|
|
|
future_exec = eastern_timezone.localize(datetime.datetime.combine(now, given_time))
|
|
|
|
|
|
|
|
# If the given time is before the current time, add one day to the future execution time
|
|
|
|
if future_exec < now:
|
|
|
|
future_exec += datetime.timedelta(days=1)
|
|
|
|
|
2024-07-19 21:26:49 +00:00
|
|
|
return (future_exec - now).total_seconds()
|