mirror of
https://github.com/wlinator/luminara.git
synced 2024-10-02 22:23:13 +00:00
19 lines
596 B
Python
19 lines
596 B
Python
import datetime
|
|
|
|
import pytz
|
|
|
|
|
|
def seconds_until(hours, minutes):
|
|
eastern_timezone = pytz.timezone("US/Eastern")
|
|
|
|
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)
|
|
|
|
return (future_exec - now).total_seconds()
|