Hello,
This bug is pretty old. But the patch attached by Kacper is trying to
patch more than just the recurring dates. Actually it doesn't apply
cleanly to current release.
So I am sending here a patch that fixes just this - the recurring
dates error. In fact - without this patch gdeskcal is almost
*unusable* because recurring dates simply don't work! The birthdays
of may family, and wedding reminder is all wrong.
It is a stripped down version of Kacper's patch.
Please, would you be kind enough to apply the attached patch and make
an updated release of gdeskcal in debian?
--
# Janek Kozicki
diff -urdp gdeskcal-0.57.1/code/planner/cal/Date.py gdeskcal-0.57.2-kw/code/planner/cal/Date.py
--- gdeskcal-0.57.1/code/planner/cal/Date.py 2006-11-19 14:03:37.000000000 +0100
+++ gdeskcal-0.57.2-kw/code/planner/cal/Date.py 2006-08-26 19:17:20.000000000 +0200
@@ -1,5 +1,5 @@
import time
-import calendar
+from calendar import monthrange,timegm
from datetime import datetime,timedelta
@@ -56,9 +56,9 @@ class Date:
#
def __utc_to_localtime(self):
- secs = calendar.timegm(self._to_time())
+ secs = timegm(self._to_time())
localtime = time.localtime(secs)
- localsecs = calendar.timegm(localtime)
+ localsecs = timegm(localtime)
diff = int(localsecs - secs)
self.add_time(0, 0, 0, 0, 0, diff)
@@ -105,27 +105,32 @@ class Date:
# Adds a given amount of time to the given date. Amounts may be negative.
#
def add_time(self, dyear, dmonth, dday, dhour = 0, dmin = 0, dsec = 0):
+
+ # print "Running add_time(%s, Y:%d, M:%d, D:%d, H:%d, M:%d, S:%d)" % (self, dyear, dmonth, dday, dhour, dmin, dsec)
+ self.__year = self.__year + dyear
+ if self.__month + dmonth > 12:
+ self.__year = self.__year + 1
+ dmonth = dmonth - 12
+ self.__month = self.__month + dmonth
+
+ (firstday, numdays) = monthrange(self.__year, self.__month)
+ if self.__day > numdays:
+ self.__day = numdays
+
old_time = self._to_time()
dt_current_time = datetime.fromtimestamp(time.mktime(old_time))
- delta = timedelta(dday, 0, 0, 0, 0, 0, dmonth * 4 + dyear * 52 )
-
+ delta = timedelta(dday, dsec, 0, 0, dmin, dhour, 0)
dt_current_time = dt_current_time + delta
-
t = dt_current_time.timetuple()
self.__year = t[0]
self.__month = t[1]
self.__day = t[2]
self.__hours = t[3]
self.__mins = t[4]
self.__secs = t[5]
- # add any hours, minutes or seconds separately. Why? -KW
- if (dhour or dmin or dsec): self.__add_daytime(dhour, dmin, dsec)
-
-
-
def __add_daytime(self, dhour, dmin, dsec):
ch, cm, cs = self.get_daytime()