Roundup Tracker - Issues

Issue 853306

classification
date arithmetic allows "December 0"
Type: Severity: normal
Components: None Versions:
process
Status: closed fixed
:
: : richard
Priority: normal :

Created on 2003-12-03 14:24 by anonymous, last changed 2003-12-04 23:06 by richard.

Messages
msg1068 Author: [hidden] (anonymous) Date: 2003-12-03 14:24
From: ron_dagostino@ssga.com

>>> from roundup.date import Date
>>> now = Date('.')
>>> yesterday = Date('-1d')
>>> now.pretty()
' 3 December 2003'
>>> yesterday.pretty()
' 2 December 2003'
>>> d = yesterday - now
>>> d.pretty()
'yesterday'
>>> x = Date('-3d')
>>> d = x - now
>>> d.pretty()
'2 days ago'     <<<<<<<<<<<<<<<<<<<
>>> x.pretty()
' 0 December 2003'   <<<<<<<<<<<<<<<<
>>> x = Date('-4d')
>>> x.pretty()
'29 November 2003'
>>> d = x - now
>>> d.pretty()
'3 days ago'
>>> 

Here is the fix in the addInterval() routine of date.py:

diff date.py~ date.py
192,194c192,194
<         while (second < 0 or second > 59 or minute < 0 
or minute > 59 or
<                 hour < 0 or hour > 59):
<             if second < 0: minute -= 1; second += 60
---
>         while (second < 1 or second > 59 or minute < 1 
or minute > 59 or
>                 hour < 1 or hour > 59):
>             if second < 1: minute -= 1; second += 60
196c196
<             if minute < 0: hour -= 1; minute += 60
---
>             if minute < 1: hour -= 1; minute += 60
198c198
<             if hour < 0: day -= 1; hour += 24
---
>             if hour < 1: day -= 1; hour += 24
211c211
<         while month < 1 or month > 12 or day < 0 or 
day > get_mdays(year,month):
---
>         while month < 1 or month > 12 or day < 1 or 
day > get_mdays(year,month):
213c213
<             if day < 0: 
---
>             if day < 1: 
bash-2.05b$ 
msg1069 Author: [hidden] (richard) Date: 2003-12-04 23:06
Logged In: YES 
user_id=6405

Fixed, minus the incorrect time calculation stuff (though I did fix the 
hours truncation to be 24 and not 60). 
History
Date User Action Args
2003-12-03 14:24:53anonymouscreate