-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
job_queue.run_daily fails for timezone aware datetime.datetime objects #1409
Comments
I have the same problem. My testing is local at BST (British Summer Time) but my hosting uses UTC time. I think personally the wrapper should use Otherwise, I also wish jobqueue.run_once(when=DT_OBJ) could accept timezone/utc_offset-aware datetime objects too. |
## Original issue ## Issue: python-telegram-bot#1409 version: 12.0.0b1 ## Changes ## The `._put()` method can now accept utc_offset-aware/timezone-aware `datetime.datetime` objects. This helps bots to be hosted on a server with any timezone without complications. To convert datetimes to UTC, a "UTC" subclass of the `datetime.tzinfo` class was added, and used in `._put()`. ## Other options considered ## - Changing all the `.now()` comparisons in `._put()` to `.utcnow()`. This was not chosen, since it would cause a major compatibility issue. Bots would have to be rewritten to pass in UTC datetimes, instead of local (computer time) datetimes, into the jobqueue.run_once and other methods. This would likely be unwanted behaivour.
## Original issue ## Issue: python-telegram-bot#1409 version: 12.0.0b1 ## Changes ## The `._put()` method can now accept utc_offset-aware/timezone-aware `datetime.datetime` objects. This helps bots to be hosted on a server with any timezone without complications. To convert datetimes to UTC, a "UTC" subclass of the `datetime.tzinfo` class was added, and used in `._put()`. ## Other options considered ## - Changing all the `.now()` comparisons in `._put()` to `.utcnow()`. This was not chosen, since it would cause a major compatibility issue. Bots would have to be rewritten to pass in UTC datetimes, instead of local (computer time) datetimes, into the jobqueue.run_once and other methods. This would likely be unwanted behaivour.
A solution in the case for
The issue still stands for |
As we mentioned on the linked closed PR. |
It would be a clean and easy solution if the user has just to calculate the UTC offset, but it can become very cumbersome for timezones with Daylight Saving Time. If you want a job to run daily on a specific time, you have to restart |
job_queue.run_daily fails for timezone aware datetime.datetime objects (version 12.0.0b1).
It would be nice if you could give timezone-information, for example, if the bot is being hosted in another timezone.
The text was updated successfully, but these errors were encountered: