dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.73k stars 960 forks source link

New Method to declare timezone: `tz()` #470

Closed chrimaho closed 11 months ago

chrimaho commented 3 years ago

I would like to define the timezone when I would like my scheduler to run.

If we take this example:

# No specified time zone. These will use the local timezone.
schedule.every().day.at("10:30").do(job)
schedule.every().wednesday.at("13:15").do(job)
schedule.every(2).days.at("17:47").do(job)

We can enhance it to add one more step to specify the required timezone.

# Defined time zone.
schedule.every().day.at("10:30").tz("America/New_York").do(job)
schedule.every().wednesday.at("13:15").tz("Australia/Sydney").do(job)
schedule.every(2).days.at("17:47").tz("Europe/London").do(job)

The benefits of this would be very very helpful. Especially for multi-national companies who need something like this to work at a specified time in a specific timezone.

rocky4546 commented 3 years ago

Currently schedule.py has no dependencies and can exists alone. This fix adds multiple packages that are not part of the standard python install. The question that should be asked is whether this file should now have required complexity. It looks like the author build this file to not add dependencies.

SijmenHuizenga commented 11 months ago

Support for timezone in .at() has been added in 1.2.0 :tada: