[Python-checkins] python/nondist/sandbox/datetime obj_date.c,1.8,1.9 test_cdatetime.py,1.7,1.8
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
2002年11月25日 22:27:26 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv16679
Modified Files:
obj_date.c test_cdatetime.py
Log Message:
date_isocalendar(): This suffered two instances of mistaking C "/" for
Python's floor division. Repaired them. test_isocalendar now passes in
the C implementation, so removed its test from test_cdatetime too.
Index: obj_date.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_date.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** obj_date.c 26 Nov 2002 06:09:53 -0000 1.8
--- obj_date.c 26 Nov 2002 06:27:24 -0000 1.9
***************
*** 260,278 ****
int week1_monday = iso_week1_monday(year);
long today = ymd_to_ord(year, GET_MONTH(self), GET_DAY(self));
! int week = (today - week1_monday) / 7;
! int day = (today - week1_monday) % 7;
if (week < 0) {
--year;
week1_monday = iso_week1_monday(year);
! week = (today - week1_monday) / 7;
! day = (today - week1_monday) % 7;
}
! else if (week >= 52 &&
! today >= iso_week1_monday(year + 1)) {
++year;
week = 0;
}
! return Py_BuildValue("iii", year, week + 1, day + 1);
}
--- 260,277 ----
int week1_monday = iso_week1_monday(year);
long today = ymd_to_ord(year, GET_MONTH(self), GET_DAY(self));
! long week;
! long day;
+ week = divmod(today - week1_monday, 7, &day);
if (week < 0) {
--year;
week1_monday = iso_week1_monday(year);
! week = divmod(today - week1_monday, 7, &day);
}
! else if (week >= 52 && today >= iso_week1_monday(year + 1)) {
++year;
week = 0;
}
! return Py_BuildValue("iii", year, (int)week + 1, (int)day + 1);
}
Index: test_cdatetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_cdatetime.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_cdatetime.py 26 Nov 2002 06:09:53 -0000 1.7
--- test_cdatetime.py 26 Nov 2002 06:27:24 -0000 1.8
***************
*** 16,39 ****
# XXX This still fails if fully enabled.
- def test_isocalendar(self):
- # Check examples from
- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
- for i in range(7):
- d = self.theclass(2003, 12, 22+i)
- self.assertEqual(d.isocalendar(), (2003, 52, i+1))
- d = self.theclass(2003, 12, 29) + timedelta(i)
- self.assertEqual(d.isocalendar(), (2004, 1, i+1))
- d = self.theclass(2004, 1, 5+i)
- self.assertEqual(d.isocalendar(), (2004, 2, i+1))
- d = self.theclass(2009, 12, 21+i)
- self.assertEqual(d.isocalendar(), (2009, 52, i+1))
- d = self.theclass(2009, 12, 28) + timedelta(i)
- ## print >>sys.__stderr__, i, `d`, d.isocalendar()
- ## self.assertEqual(d.isocalendar(), (2009, 53, i+1))
- d = self.theclass(2010, 1, 4+i)
- self.assertEqual(d.isocalendar(), (2010, 1, i+1))
-
-
- # XXX This still fails if fully enabled.
def test_extreme_timedelta(self):
big = self.theclass.max - self.theclass.min
--- 16,19 ----