summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 42c912a)
raw | patch | inline | side by side (parent: 42c912a)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 14 Jul 2002 06:05:50 +0000 (06:05 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 14 Jul 2002 06:05:50 +0000 (06:05 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@873 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/admin.py | patch | blob | history | |
roundup/date.py | patch | blob | history | |
test/test_dates.py | patch | blob | history |
diff --git a/roundup/admin.py b/roundup/admin.py
index e54ef7c609ebfbb4ddcf646311e0922bfa1b4c40..b8cfb840bb81fce6cfcd55b24849d76940b65354 100644 (file)
--- a/roundup/admin.py
+++ b/roundup/admin.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: admin.py,v 1.16 2002-07-09 04:19:09 richard Exp $
+# $Id: admin.py,v 1.17 2002-07-14 06:05:50 richard Exp $
import sys, os, getpass, getopt, re, UserDict, shlex, shutil
try:
raise ValueError, _('Invalid format')
m = m.groupdict()
if m['period']:
- # TODO: need to fix date module. one should be able to say
- # pack_before = date.Date(". - %s"%value)
- pack_before = date.Date(".") + date.Interval("- %s"%value)
+ pack_before = date.Date(". - %s"%value)
elif m['date']:
pack_before = date.Date(value)
self.db.pack(pack_before)
#
# $Log: not supported by cvs2svn $
+# Revision 1.16 2002/07/09 04:19:09 richard
+# Added reindex command to roundup-admin.
+# Fixed reindex on first access.
+# Also fixed reindexing of entries that change.
+#
# Revision 1.15 2002/06/17 23:14:44 richard
# . #569415 ] {version}
#
diff --git a/roundup/date.py b/roundup/date.py
index c40c4dc3288fda5b2475d3fe0df5f14baf46e561..94db02e986bbc7a450ef5b64a535db7f5c9c613d 100644 (file)
--- a/roundup/date.py
+++ b/roundup/date.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: date.py,v 1.21 2002-05-15 06:32:46 richard Exp $
+# $Id: date.py,v 1.22 2002-07-14 06:05:50 richard Exp $
__doc__ = """
Date, time and time interval handling.
self.year, self.month, self.day, self.hour, self.minute, \
self.second, x, x, x = time.gmtime(ts)
- def applyInterval(self, interval):
- ''' Apply the interval to this date
+ def addInterval(self, interval):
+ ''' Add the interval to this date, returning the date tuple
'''
- t = (self.year + interval.year,
- self.month + interval.month,
- self.day + interval.day,
- self.hour + interval.hour,
- self.minute + interval.minute,
- self.second + interval.second, 0, 0, 0)
- self.year, self.month, self.day, self.hour, self.minute, \
- self.second, x, x, x = time.gmtime(calendar.timegm(t))
-
- def __add__(self, other):
- """Add an interval to this date to produce another date.
- """
# do the basic calc
- sign = other.sign
- year = self.year + sign * other.year
- month = self.month + sign * other.month
- day = self.day + sign * other.day
- hour = self.hour + sign * other.hour
- minute = self.minute + sign * other.minute
- second = self.second + sign * other.second
+ sign = interval.sign
+ year = self.year + sign * interval.year
+ month = self.month + sign * interval.month
+ day = self.day + sign * interval.day
+ hour = self.hour + sign * interval.hour
+ minute = self.minute + sign * interval.minute
+ second = self.second + sign * interval.second
# now cope with under- and over-flow
# first do the time
# re-figure the number of days for this month
if month == 2 and calendar.isleap(year): month_days = 29
else: month_days = mdays[month]
+ return (year, month, day, hour, minute, second, 0, 0, 0)
- return Date((year, month, day, hour, minute, second, 0, 0, 0))
+ def applyInterval(self, interval):
+ ''' Apply the interval to this date
+ '''
+ self.year, self.month, self.day, self.hour, self.minute, \
+ self.second, x, x, x = self.addInterval(interval)
+
+ def __add__(self, interval):
+ """Add an interval to this date to produce another date.
+ """
+ return Date(self.addInterval(interval))
# XXX deviates from spec to allow subtraction of dates as well
def __sub__(self, other):
#
# $Log: not supported by cvs2svn $
+# Revision 1.21 2002/05/15 06:32:46 richard
+# . reverting to dates for intervals > 2 months sucks
+#
# Revision 1.20 2002/02/21 23:34:51 richard
# Oops, there's 24 hours in a day, and subtraction of intervals now works
# properly.
diff --git a/test/test_dates.py b/test/test_dates.py
index 14da7ec56adbd0cac24b0b85e91fb2d2bf36d403..942aa57f8c0f936b0f0a36843948d508f6db2793 100644 (file)
--- a/test/test_dates.py
+++ b/test/test_dates.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_dates.py,v 1.11 2002-02-21 23:34:52 richard Exp $
+# $Id: test_dates.py,v 1.12 2002-07-14 06:05:50 richard Exp $
import unittest, time
# now check calculations
date = Date('2000-01-01') + Interval('- 2y 2m')
ae(str(date), '1997-11-01.00:00:00')
+ date = Date('2000-01-01 - 2y 2m')
+ ae(str(date), '1997-11-01.00:00:00')
date = Date('2000-01-01') + Interval('2m')
ae(str(date), '2000-03-01.00:00:00')
+ date = Date('2000-01-01 + 2m')
+ ae(str(date), '2000-03-01.00:00:00')
date = Date('2000-01-01') + Interval('60d')
ae(str(date), '2000-03-01.00:00:00')
#
# $Log: not supported by cvs2svn $
+# Revision 1.11 2002/02/21 23:34:52 richard
+# Oops, there's 24 hours in a day, and subtraction of intervals now works
+# properly.
+#
# Revision 1.10 2002/02/21 23:11:45 richard
# . fixed some problems in date calculations (calendar.py doesn't handle over-
# and under-flow). Also, hour/minute/second intervals may now be more than