Skip to content
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

Use django.utils.timezone.now instead of datetime.now for timez… #2323

Merged
merged 4 commits into from
Oct 2, 2019

Conversation

jezdez
Copy link
Contributor

@jezdez jezdez commented Oct 2, 2019

We should make sure to always use django.utils.timezone.now instead of datetime.datetime.now so datetimes for database content are timezone-aware. datetimes created by datetime.datetime.now don't have any tzinfo and are basically creating race conditions.

Pull Request checklist

  • Documentation: If this feature has or requires documentation, the relevant docs have been updated.
  • Changelog: This PR updates the changelog with any user-visible changes.
  • Tests: This PR includes thorough tests or an explanation of why it does not

@jezdez jezdez requested a review from wlach October 2, 2019 11:08
Copy link
Contributor

@wlach wlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM though the unit tests are failing. Also same comment about the redundant unreleased header in the changelog that I noted last time :)

@codecov-io
Copy link

codecov-io commented Oct 2, 2019

Codecov Report

Merging #2323 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2323      +/-   ##
==========================================
+ Coverage   69.34%   69.35%   +0.01%     
==========================================
  Files         220      220              
  Lines        5333     5335       +2     
  Branches      854      854              
==========================================
+ Hits         3698     3700       +2     
  Misses       1606     1606              
  Partials       29       29
Impacted Files Coverage Δ
server/files/tasks.py 100% <100%> (ø) ⬆️
server/tests/test_file_update_operations.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c16d9b7...6622f0a. Read the comment docs.

@jezdez jezdez changed the title Use django.utils.timezone.now instead of datetime.now for timezone-aware datetimes. Use django.utils.timezone.now instead of datetime.now for timez… Oct 2, 2019
@jezdez jezdez merged commit 0770a1a into master Oct 2, 2019
@jezdez jezdez deleted the datetime-timezone branch October 2, 2019 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants