Package: gdeskcal
Version: 0.57.1-2
After correspondence with Martin Grimme I realized my previous patch
(which has been applied in 0.57.1-2) generates recurrences every 4
weeks for events which recur monthly, which is not the correct
behaviour. E.g. I have created an event "Test" on August 31st,
recurring every month for 10 times:
* August 31st
* September 28th
* October 26th
* November 23rd
* December 21st
...
* May 10th <- not really end of month... ;)
Attached is a little patch that adds the year and month first, then
changes the day to the last day of the month if it's out of range,
thereby calculating the recurring date correctly.
There's a problem with this method, however: the fallback sticks, so
an event originally set to the 31st will be on the 30th until it hits
February, when it'll stick as 29th for leap years, or 28th forever
after. This is because the next recurrence of an event is calculated
based on the previous occurance, not based on the original occurence.
Fixing this will require a more intrusive patch.
diff -urdp gdeskcal-0.57.1/code/CalMediator.py gdeskcal-0.57.2-kw/code/CalMediator.py
--- gdeskcal-0.57.1/code/CalMediator.py 2006-11-19 14:03:37.000000000 +0100
+++ gdeskcal-0.57.2-kw/code/CalMediator.py 2006-05-09 21:33:58.400603120 +0200
@@ -105,6 +105,7 @@ class CalMediator:
# configure
self.set_config(self.__config)
+ self.__window.set_keep_below(True)
diff -urdp gdeskcal-0.57.1/code/planner/CalEditor.py gdeskcal-0.57.2-kw/code/planner/CalEditor.py
--- gdeskcal-0.57.1/code/planner/CalEditor.py 2006-11-19 14:03:37.000000000 +0100
+++ gdeskcal-0.57.2-kw/code/planner/CalEditor.py 2006-05-09 22:06:59.166480936 +0200
@@ -217,9 +217,11 @@ class CalEditor(gtk.Dialog):
elif (p and p[0] == "{"):
entries = p[1:-1].split("|")
# The GTK devs deprecated OptionMenu in favor of ComboBox
# but there is no quick way to fix it, ComboBox is a beast in
# comparison to this simplicity. --KW
+ # addendum:
+ # However, ComboBoxen can't be set_keep_below(False)
option = gtk.OptionMenu()
option.show()
menu = gtk.Menu()
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()