Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Avoiding common pitfalls of
datetime from a webapp's
perspective
PyCon India - 2015
Indradhanush Gupta
About me
● Love Python + Emacs
● ZeroMQ, Twisted, Django
● Graduated in 2014
● Software Engineer @ Instamojo
Target Audience
● Beginner in Python
● Web developer
● And anyone else!
import datetime
● Naive vs Aware
● Datetime storage in Postgres
● Should I ever use a naive datetime object?
import pytz
● Adding timezone info to naive datetime
● Converting datetime to another timezone
● Do not use datetime.datet...
import production
● Examples from real life and experience.
import production
● 10 AM for the user != 10 AM in your DB
import freezegun
● Writing tests that need to mock datetime
● Using freezegun instead of mock
● Examples
import extras
● timedelta
● dateutil.relativedelta
● dateutil.parser
import questions
Thank You!
Upcoming SlideShare
Loading in …5
×

Avoiding common pitfalls of datetime from a webapp's perspective

679 views

Published on

Slides for my proposed talk at PyCon India, 2015.

Published in: Technology
  • Be the first to comment

Avoiding common pitfalls of datetime from a webapp's perspective

  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!

×