[pygtk] Sorting dates in a liststore

2009-03-09 Thread 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/, 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?
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Sorting dates in a liststore

2009-03-09 Thread Stefan Stuhr
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/, 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 (-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

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/