Permalink
Browse files

Use `date` rather than `datetime` for storing dates.

  • Loading branch information...
1 parent 27dff37 commit c2ef5d143f1bfc9931ef9f7487fda3b93780fe8f @wagnerrp wagnerrp committed May 1, 2012
Showing with 7 additions and 8 deletions.
  1. +7 −8 tmdb3/tmdb_api.py
View
@@ -59,6 +59,9 @@
DEBUG = False
+def process_date(datestr):
+ return datetime.date(*[int(x) for x in datestr.split('-')])
+
class Configuration( Element ):
images = Datapoint('images')
def _populate(self):
@@ -176,10 +179,8 @@ class Person( Element ):
id = Datapoint('id', initarg=1)
name = Datapoint('name')
biography = Datapoint('biography')
- dayofbirth = Datapoint('birthday', default=None, handler=lambda x: \
- datetime.datetime.strptime(x, '%Y-%m-%d'))
- dayofdeath = Datapoint('deathday', default=None, handler=lambda x: \
- datetime.datetime.strptime(x, '%Y-%m-%d'))
+ dayofbirth = Datapoint('birthday', default=None, handler=process_date)
+ dayofdeath = Datapoint('deathday', default=None, handler=process_date)
homepage = Datapoint('homepage')
birthplace = Datapoint('place_of_birth')
profile = Datapoint('profile_path', handler=Profile, raw=False)
@@ -226,8 +227,7 @@ def __repr__(self):
class Release( Element ):
certification = Datapoint('certification')
country = Datapoint('iso_3166_1')
- releasedate = Datapoint('release_date', handler=lambda x: \
- datetime.datetime.strptime(x, '%Y-%m-%d'))
+ releasedate = Datapoint('release_date', handler=process_date)
def __repr__(self):
return u"<Release {0.country}, {0.releasedate}>".format(self)
@@ -385,8 +385,7 @@ def fromIMDB(cls, imdbid, locale=None):
runtime = Datapoint('runtime')
budget = Datapoint('budget')
revenue = Datapoint('revenue')
- releasedate = Datapoint('release_date', handler=lambda x: \
- datetime.date(*[int(y) for y in x.split('-')]))
+ releasedate = Datapoint('release_date', handler=process_date)
homepage = Datapoint('homepage')
imdb = Datapoint('imdb_id')

0 comments on commit c2ef5d1

Please sign in to comment.