[chronojump] Fixed dateColumnCompare for all cultures on load session window



commit f1d4baf8dd5f08ea0e0ec1da167b98d80098c971
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 28 16:34:52 2017 +0200

    Fixed dateColumnCompare for all cultures on load session window

 src/gui/session.cs |   17 ++++++++++++-----
 src/utilGtk.cs     |    6 ------
 2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/gui/session.cs b/src/gui/session.cs
index b414b6a..8c37818 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -787,12 +787,19 @@ public class SessionLoadWindow {
 
        private static int dateColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2)
        {
-               DateTime val1;
-               DateTime val2;
-               val1 = UtilDate.FromSql(model.GetValue(iter1, 1).ToString());
-               val2 = UtilDate.FromSql(model.GetValue(iter2, 1).ToString());
+               var dt1String = (model.GetValue(iter1, 1).ToString());
+               var dt2String = (model.GetValue(iter2, 1).ToString());
 
-               return DateTime.Compare(val1, val2);
+               DateTime dt1;
+               DateTime dt2;
+
+               var converted1 = DateTime.TryParse(dt1String, out dt1);
+               var converted2 = DateTime.TryParse(dt2String, out dt2);
+
+               if(converted1 && converted2)
+                       return DateTime.Compare(dt1, dt2);
+               else
+                       return 0;
        }
        
        static public SessionLoadWindow Show (Gtk.Window parent, WindowType type)
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 0702ea2..c91aab3 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -276,12 +276,6 @@ public class UtilGtk
         * Search for dateColumnCompare
         *
        public static int DateColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2)     {
-               DateTime val1;
-               DateTime val2;
-               val1 = UtilDate.FromSql(model.GetValue(iter1, 3).ToString());
-               val2 = UtilDate.FromSql(model.GetValue(iter2, 3).ToString());
-
-               return DateTime.Compare(val1, val2);
        }
        */
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]