refactor: update all_day
detection logic
#2601
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Instead of using a particular resolution on an object, which differs between
datetime.date
anddatetime.datetime
objects, operate on parent class ofdatetime
and convert alldt
to timezone-awaredatetime
values.This is also in accordance to the model field being a
DateTimeField
, so we should always be passing the correctly-created object, instead of adatetime.date()
, raisingreceived a naive datetime
warnings.Removes unused constants.
Closes
Closes #2415
Other notes, for fun.
The warnings stem from this little bitty function:
pythondotorg/events/utils.py
Lines 23 to 26 in 8a02c10
Since the ICS importer is often met with a string that looks like a date-only, like this one:
pythondotorg/events/tests/test_importer.py
Line 39 in 8a02c10
the returned type is
datetime.date
, not adatetime.datetime
.The change in
events/utils.py
drops the warnings, but fails two test cases:These come from the
all_day
calculation over here:pythondotorg/events/importer.py
Lines 33 to 37 in 74e659c
which has now been updated.