File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -140,19 +140,20 @@ def add_duration(tid, duration):
140
140
carry = f_quotient (temp , 60 )
141
141
# hours
142
142
temp = tid .tm_hour + dur ["tm_hour" ] + carry
143
- hour = modulo (temp , 60 )
144
- carry = f_quotient (temp , 60 )
143
+ hour = modulo (temp , 24 )
144
+ carry = f_quotient (temp , 24 )
145
145
# days
146
- if dur [ " tm_mday" ] > maximum_day_in_month_for (year , month ):
146
+ if tid . tm_mday > maximum_day_in_month_for (year , month ):
147
147
temp_days = maximum_day_in_month_for (year , month )
148
- elif dur [ " tm_mday" ] < 1 :
148
+ elif tid . tm_mday < 1 :
149
149
temp_days = 1
150
150
else :
151
- temp_days = dur [ " tm_mday" ]
152
- days = temp_days + tid . tm_mday + carry
151
+ temp_days = tid . tm_mday
152
+ days = temp_days + dur [ " tm_mday" ] + carry
153
153
while True :
154
154
if days < 1 :
155
- pass
155
+ days = days + maximum_day_in_month_for (year , month - 1 )
156
+ carry = - 1
156
157
elif days > maximum_day_in_month_for (year , month ):
157
158
days -= maximum_day_in_month_for (year , month )
158
159
carry = 1
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ def test_parse_duration_n():
92
92
assert d == _val
93
93
94
94
def test_add_duration_1 ():
95
- #2000-01-12T12:13:14Z P1Y3M5DT7H10M3S 2001-04-17T19:23:17Z
95
+ #2000-01-12T12:13:14Z P1Y3M5DT7H10M3S 2001-04-17T19:23:17Z
96
96
t = add_duration (str_to_time ("2000-01-12T12:13:14Z" ), "P1Y3M5DT7H10M3S" )
97
97
assert t .tm_year == 2001
98
98
assert t .tm_mon == 4
@@ -107,7 +107,7 @@ def test_add_duration_2():
107
107
t = add_duration (str_to_time ("2000-01-12T00:00:00Z" ), "PT33H" )
108
108
assert t .tm_year == 2000
109
109
assert t .tm_mon == 1
110
- assert t .tm_mday == 14
110
+ assert t .tm_mday == 13
111
111
assert t .tm_hour == 9
112
112
assert t .tm_min == 0
113
113
assert t .tm_sec == 0
@@ -119,7 +119,7 @@ def test_str_to_time():
119
119
#t = time.mktime(str_to_time("2000-01-12T00:00:00Z"))
120
120
#assert t == 947631600.0
121
121
#TODO: add something to show how this time was arrived at
122
- # do this as an external method in the
122
+ # do this as an external method in the
123
123
assert t == 947635200
124
124
# some IdPs omit the trailing Z, and SAML spec is unclear if it is actually required
125
125
t = calendar .timegm (str_to_time ("2000-01-12T00:00:00" ))
You can’t perform that action at this time.
0 commit comments