dbader / schedule

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

Add timezone support for .at() #517

Closed SijmenHuizenga closed 2 years ago

SijmenHuizenga commented 2 years ago

Add a timezone parameter to the .at() method:

schedule.every().day.at("12:42", "Asia/Jakarta").do(job)

During next-job-calculation, the next run is translated from the set timezone into the local timezone so that all jobs are being scheduled in the same timezone.

This implementation of timezone-support is inspired by #471, difference here is that pytz is an optional dependency. Pytz is only required when using timezones. This ensures that people can keep using schedule without other dependencies.

What do you think? Feedback & Reviews is welcome!

coveralls commented 2 years ago

Coverage Status

Coverage increased (+0.01%) to 99.711% when pulling b2ba6d69eaf2f5207fc6ca0c60a59d338c72426d on SijmenHuizenga:feature/timezones into ed7d21961242f86342da240ee1d089c1cee37de6 on dbader:master.

SijmenHuizenga commented 2 years ago

Configured tox to run all test twice: First without pytz, then with pytz. This makes sure that the library is in perfectly usable without pytz installed. Test-coverage is measured from the tests that do include pytz.

I think this pr is ready to be merged & released, but will leave it open a few days for feedback.

SijmenHuizenga commented 2 years ago

Thank you @chrimaho so much for the review! Super helpful comments :rocket: