Commits

Brandon Nielsen  committed 594b53b

Sync python3 version.

  • Participants
  • Parent commits 5b84fd5

Comments (0)

Files changed (1)

File python3/aniso8601/duration.py

         return parse_duration_combined(isodurationstr)
 
 def parse_duration_prescribed(durationstr):
-    #durationstr can be of the form PnYnMnDTnHnMnS
+    #durationstr can be of the form PnYnMnDTnHnMnS or PnW
 
     #Make sure only the lowest order element has decimal precision
     if durationstr.count('.') > 1:
         else:
             seconds = 0
 
-    totaldays = years * 365 + months * 30 + weeks * 7 + days
+    #Note that weeks can be handled without conversion to days
+    totaldays = years * 365 + months * 30 + days
 
-    return datetime.timedelta(days=totaldays, hours=hours, minutes=minutes, seconds=seconds)
+    return datetime.timedelta(weeks=weeks, days=totaldays, hours=hours, minutes=minutes, seconds=seconds)
 
 def parse_duration_combined(durationstr):
     #Period of the form P<date>T<time>