From e226c06de68c20297dc491df5ef14f8c205986c3 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 5 Jan 2008 03:02:56 +0000 Subject: [PATCH] 2008-01-04 Douglas S. Blank * src/gen/lib/date.py (Date.__sub__): fixed date differences * src/Simple/_SimpleTable.py: removed frame around textview svn: r9709 --- ChangeLog | 4 ++++ src/Simple/_SimpleTable.py | 6 ++---- src/gen/lib/date.py | 29 ++++++++++++++++------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b1ff0238..46e43a103 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-01-04 Douglas S. Blank + * src/gen/lib/date.py (Date.__sub__): fixed date differences + * src/Simple/_SimpleTable.py: removed frame around textview + 2008-01-04 Gary Burton * src/plugins/Verify.py: Allow the Verify Results window to be reused if it is already instantiated. Bug #1532 diff --git a/src/Simple/_SimpleTable.py b/src/Simple/_SimpleTable.py index 063503d83..dd3f23e92 100644 --- a/src/Simple/_SimpleTable.py +++ b/src/Simple/_SimpleTable.py @@ -284,18 +284,16 @@ class SimpleTable: if self.title: self.simpledoc.paragraph(self.title) # Make a GUI to put the tree view in - frame = gtk.Frame() - frame.add(treeview) types += sort_data_types model = gtk.ListStore(*types) treeview.set_model(model) iter = buffer.get_end_iter() anchor = buffer.create_child_anchor(iter) - text_view.add_child_at_anchor(frame, anchor) + text_view.add_child_at_anchor(treeview, anchor) count = 0 for data in self.__rows: model.append(row=([count] + list(data) + [col[count] for col in sort_data])) count += 1 - frame.show_all() + text_view.show_all() self.simpledoc.paragraph("") self.simpledoc.paragraph("") diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index 9a7fee41c..bc57fb77d 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -252,29 +252,32 @@ class Date: if type(other) == int: return self.copy_offset_ymd(-other) elif type(other) == type(self): # date - d1 = self.get_ymd() - d2 = other.get_ymd() + d1 = map(lambda i: i or 1, self.get_ymd()) + d2 = map(lambda i: i or 1, other.get_ymd()) if d1 < d2: d1, d2 = d2, d1 + # d1 - d2 (1998, 12, 32) - (1982, 12, 15) = + # days: + if d2[2] > d1[2]: + # months: + if d2[1] > d1[1]: + d1[0] -= 1 + d1[1] += 12 + d1[1] -= 1 + d1[2] += 31 + # months: + if d2[1] > d1[1]: + d1[0] -= 1 # from years + d1[1] += 12 # to months days = d1[2] - d2[2] months = d1[1] - d2[1] years = d1[0] - d2[0] - while days < 0: - months -= 1 - days = 30 + days - while months < 0: - years -= 1 - months = 12 + months if days > 31: months += days / 31 days = days % 31 - if months > 11: + if months > 12: years += months / 12 months = months % 12 - if years < 0: # can happen with 0 based months/days - years = 0 - months = 12 - months - days = 31 - days return (years, months, days) elif type(other) in [tuple, list]: return self.copy_offset_ymd(*map(lambda x: -x, other))