Ticket #4768: dateformat_timesince_cleanup.diff
File dateformat_timesince_cleanup.diff, 1.5 KB (added by , 17 years ago) |
---|
-
django/utils/timesince.py
33 33 delta = now - (d - datetime.timedelta(0, 0, d.microsecond)) 34 34 since = delta.days * 24 * 60 * 60 + delta.seconds 35 35 for i, (seconds, name) in enumerate(chunks): 36 count = since / seconds36 count = since // seconds 37 37 if count != 0: 38 38 break 39 if count < 0:40 return ugettext('%d milliseconds') % math.floor((now - d).microseconds / 1000)41 39 s = ugettext('%(number)d %(type)s') % {'number': count, 'type': name(count)} 42 40 if i + 1 < len(chunks): 43 41 # Now get the second item 44 42 seconds2, name2 = chunks[i + 1] 45 count2 = (since - (seconds * count)) / seconds243 count2 = (since - (seconds * count)) // seconds2 46 44 if count2 != 0: 47 45 s += ugettext(', %(number)d %(type)s') % {'number': count2, 'type': name2(count2)} 48 46 return s -
django/utils/dateformat.py
227 227 week_number = 1 228 228 else: 229 229 j = day_of_year + (7 - weekday) + (jan1_weekday - 1) 230 week_number = j / 7230 week_number = j // 7 231 231 if jan1_weekday > 4: 232 232 week_number -= 1 233 233 return week_number