[pygtk] Sorting dates in a liststore
Stefan Stuhr
gnomelists at sstuhr.dk
Tue Mar 10 02:45:57 WST 2009
man, 09 03 2009 kl. 18:33 +0100, skrev Timo:
> In my program, the user can enter a date in a entry (and some other data
> too) and it'll append in a liststore/treeview.
> I'm having problems sorting this date column. Since notations of dates
> are different around the world ( dd/mm/yyyy, mm/dd/yy, dd-mm/yy, etc.),
> how can this be done?
> Do I have to replace the entry with 3 spinbuttons perhaps? But how can I
> put them all in one column together, and to be sortable?
Add yet another column to your *liststore*, and use that model column
for sorting of the visible treeview column.
Depending on your application, using an integer containing seconds since
epoch[1] may be fitting, alternately you can use a string containing an
ISO date (YYYY-MM-DD, 2009-03-09 for today in my timezone), that works
very well for sorting. It doesn't really matter, as it won't be visible
for users.
[1]: As returned by time.time() from the time module for current UTC
time.
Stefan
More information about the pygtk
mailing list