Commits

Brandon Nielsen committed 575b76e

Smarter casting between datetime and date.

  • Participants
  • Parent commits f9060ca

Comments (0)

Files changed (1)

File aniso8601/__init__.py

         parseddatetime = datetime.datetime.strptime(datestr, '%Y-%m-%d')
 
         #Since no 'time' is given, cast to a date
-        return datetime.date(parseddatetime.year, parseddatetime.month, parseddatetime.day)
+        return parseddatetime.date()
     elif datestrlen == 8:
         #YYYYMMDD
         parseddatetime = datetime.datetime.strptime(datestr, '%Y%m%d')
 
         #Since no 'time' is given, cast to a date
-        return datetime.date(parseddatetime.year, parseddatetime.month, parseddatetime.day)
+        return parseddatetime.date()
     elif datestrlen == 7:
         #YYYY-MM
         parseddatetime = datetime.datetime.strptime(datestr, '%Y-%m')
 
         #Since no 'time' is given, cast to a date
-        return datetime.date(parseddatetime.year, parseddatetime.month, parseddatetime.day)
+        return parseddatetime.date()
     else:
         raise ValueError('String is not a valid ISO8601 calendar date.')