plammens · GitHub

(cherry-picked from  c6dd3d7 .
I've included the refactoring mentioned in python-telegram-bot#1497 to facilitate the
change.)
There was inconsistent use of UTC vs local times. For instance, in the
former `_timestamp` helper (now `_datetime_to_float_timestamp`), assumed
that naive `datetime.datetime` objects were in the local timezone, while
the `from_timestamp` helper —which I would have thought was the
corresponding inverse function— returned naïve objects in UTC.
This meant that, for instance, `telegram.Message` objects' `date` field
was constructed as a naïve `datetime.datetime` (from the timestamp sent
by Telegram's server) in *UTC*, but when it was stored in `JSON` format
through the `to_json` method, the naïve `date` would be assumed to be in
*local time*, thus generating a different timestamp from the one it was
built from.
See python-telegram-bot#1505 for extended discussion.
Some tests/test fixtures that were using `datetime.datetime.now()` as
a test value, were changed to `datetime.datetime.utcnow()`, since now
everything is (hopefully) expecting UTC for naive datetimes.

jh0ker

@plammens

@jh0ker

tsnoam

tsnoam

 Conflicts:
	tests/test_bot.py

@plammens

A job shouldn't (and can't) be enqueued with `next_t = None`. An
exception should be raised at `_put` before an obscure error occurs
later down the line.

@plammens

@plammens

@tsnoam

@tsnoam

Closed

Closed

Merged

@n5y n5y mentioned this pull request

Dec 8, 2019

Closed

Read the original on github.com ↗