comparison roundup/date.py @ 3702:06d7816976bc

python 2.6 compatibility
author Richard Jones <richard@users.sourceforge.net>
date Sat, 09 Sep 2006 05:50:17 +0000
parents df7bff6f8a2f
children 842f1a292ff8
comparison
equal deleted inserted replaced
3701:c648bebf021e 3702:06d7816976bc
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: date.py,v 1.87 2006-05-06 16:43:29 a1s Exp $ 18 # $Id: date.py,v 1.88 2006-09-09 05:50:17 richard Exp $
19 19
20 """Date, time and time interval handling. 20 """Date, time and time interval handling.
21 """ 21 """
22 __docformat__ = 'restructuredtext' 22 __docformat__ = 'restructuredtext'
23 23
730 # the other is a Date - produce a Date 730 # the other is a Date - produce a Date
731 return Date(other.addInterval(self), translator=self.translator) 731 return Date(other.addInterval(self), translator=self.translator)
732 elif isinstance(other, Interval): 732 elif isinstance(other, Interval):
733 # add the other Interval to this one 733 # add the other Interval to this one
734 a = self.get_tuple() 734 a = self.get_tuple()
735 as = a[0] 735 asgn = a[0]
736 b = other.get_tuple() 736 b = other.get_tuple()
737 bs = b[0] 737 bsgn = b[0]
738 i = [as*x + bs*y for x,y in zip(a[1:],b[1:])] 738 i = [asgn*x + bsgn*y for x,y in zip(a[1:],b[1:])]
739 i.insert(0, 1) 739 i.insert(0, 1)
740 i = fixTimeOverflow(i) 740 i = fixTimeOverflow(i)
741 return Interval(i, translator=self.translator) 741 return Interval(i, translator=self.translator)
742 # nope, no idea what to do with this other... 742 # nope, no idea what to do with this other...
743 raise TypeError, "Can't add %r"%other 743 raise TypeError, "Can't add %r"%other
750 return Date(other.addInterval(interval), 750 return Date(other.addInterval(interval),
751 translator=self.translator) 751 translator=self.translator)
752 elif isinstance(other, Interval): 752 elif isinstance(other, Interval):
753 # add the other Interval to this one 753 # add the other Interval to this one
754 a = self.get_tuple() 754 a = self.get_tuple()
755 as = a[0] 755 asgn = a[0]
756 b = other.get_tuple() 756 b = other.get_tuple()
757 bs = b[0] 757 bsgn = b[0]
758 i = [as*x - bs*y for x,y in zip(a[1:],b[1:])] 758 i = [asgn*x - bsgn*y for x,y in zip(a[1:],b[1:])]
759 i.insert(0, 1) 759 i.insert(0, 1)
760 i = fixTimeOverflow(i) 760 i = fixTimeOverflow(i)
761 return Interval(i, translator=self.translator) 761 return Interval(i, translator=self.translator)
762 # nope, no idea what to do with this other... 762 # nope, no idea what to do with this other...
763 raise TypeError, "Can't add %r"%other 763 raise TypeError, "Can't add %r"%other

Roundup Issue Tracker: http://roundup-tracker.org/