Skip to content

Commit

Permalink
Use date rather than datetime for storing dates.
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerrp committed May 1, 2012
1 parent 27dff37 commit c2ef5d1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tmdb3/tmdb_api.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit c2ef5d1

Please sign in to comment.