Support for tz-aware datetime.datetime objects#1451
Support for tz-aware datetime.datetime objects#1451torresjrjr wants to merge 1 commit intopython-telegram-bot:masterfrom
Conversation
## 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.
|
Hi @torresjrjr Could you add those please? |
|
Actually, I like to open this for discussion with the other maintainers. |
|
@tsnoam the point they make in the issue, is that sometimes you want to use |
|
Well, that's a subset of what a timezone is. |
|
Actually, I'm not so invested in this PR as much, since this was an attempt at a solution to a problem I later solved. I wanted to "help my bot to be hosted on a server with any timezone without complications" but I ended up simply adding an extra step in my code. I created a I should also stress that I'm a python noob/intermediate. I find PRs scary. So please, take my idea and do what you will. Thanks. |
|
We were debating whether this should be a here, in helpers or in the programmers hands. I guess you helped us answering that. I'm closing this PR. |
Original issue
Issue: #1409
version: 12.0.0b1
Changes
The
._put()method can now accept utc_offset-aware/timezone-awaredatetime.datetimeobjects. 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.tzinfoclass was added, and used in._put().Other options considered
.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.