avoiding common pitfalls of datetime from a webapp's perspective

Post on 12-Aug-2015

67 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

  1. 1. Avoiding common pitfalls of datetime from a webapp's perspective PyCon India - 2015 Indradhanush Gupta
  2. 2. About me Love Python + Emacs ZeroMQ, Twisted, Django Graduated in 2014 Software Engineer @ Instamojo
  3. 3. Target Audience Beginner in Python Web developer And anyone else!
  4. 4. import datetime Naive vs Aware Datetime storage in Postgres Should I ever use a naive datetime object?
  5. 5. import pytz Adding timezone info to naive datetime Converting datetime to another timezone Do not use datetime.datetime.replace
  6. 6. import production Examples from real life and experience.
  7. 7. import production 10 AM for the user != 10 AM in your DB
  8. 8. import freezegun Writing tests that need to mock datetime Using freezegun instead of mock Examples
  9. 9. import extras timedelta dateutil.relativedelta dateutil.parser
  10. 10. import questions
  11. 11. Thank You!

top related