2008-01-04 Douglas S. Blank <dblank@cs.brynmawr.edu>

* src/gen/lib/date.py (Date.__sub__): fixed date differences
	* src/Simple/_SimpleTable.py: removed frame around textview
	


svn: r9709
This commit is contained in:
Doug Blank 2008-01-05 03:02:56 +00:00
parent d999733c22
commit e226c06de6
3 changed files with 22 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2008-01-04 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/gen/lib/date.py (Date.__sub__): fixed date differences
* src/Simple/_SimpleTable.py: removed frame around textview
2008-01-04 Gary Burton <gary.burton@zen.co.uk>
* src/plugins/Verify.py: Allow the Verify Results window to be reused if
it is already instantiated. Bug #1532

View File

@ -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("")

View File

@ -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))