[chronojump] db 0.71 to 0.72, all SQL dates to YYYY-MM-DD



commit dcabd5517ca47c22ad3d5b2c1caceea773fae230
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Aug 24 16:53:22 2009 +0200

    db 0.71 to 0.72, all SQL dates to YYYY-MM-DD
    now can know years of everyone like this:
    SELECT (julianday('now') - julianday(dateBorn))/365.25 FROM person WHERE uniqueID = 152;
    all code manages dates in DateTime or sqlite format
    
    done age on gui query server
    
    when calendar is shown on person,
    it starts showing previous value of that person (instead of current day),
    except if person is new.
    same for session and evaluator
    
    uploadSession progressBar finish ok because not counts the notUpload persons
    
    chronojump_mini writes to a file in correct dir
    
    make clean does not delete images/chronojump_logo.png images/report_web_style.css
    git added images/chronojump_logo.png images/report_web_style.css src/utilDate.cs

 TODO.txt                                   |    2 +
 chronojump_server/Makefile.am              |    1 +
 chronojump_server/bin/chronojumpServer.dll |  Bin 268800 -> 271360 bytes
 glade/chronojump.glade                     |  288 ++++++++++++++++++++++------
 images/xcf/chronojump_logo.png             |  Bin 9899 -> 0 bytes
 src/Makefile.am                            |    4 +-
 src/chronojump_mini.cs                     |   46 ++---
 src/gui/dialogCalendar.cs                  |   22 ++-
 src/gui/dialogServerStats.cs               |    2 +-
 src/gui/evaluator.cs                       |   11 +-
 src/gui/person.cs                          |   31 ++--
 src/gui/queryServer.cs                     |  108 ++++++++++-
 src/gui/session.cs                         |   18 +-
 src/log.cs                                 |    2 +-
 src/person.cs                              |   22 +--
 src/server.cs                              |   12 +-
 src/serverEvaluator.cs                     |    8 +-
 src/serverPing.cs                          |    8 +-
 src/session.cs                             |   28 ++--
 src/sqlite/main.cs                         |  107 ++++++++++-
 src/sqlite/person.cs                       |   16 +-
 src/sqlite/personSession.cs                |   14 +-
 src/sqlite/server.cs                       |   18 +-
 src/sqlite/session.cs                      |   35 ++--
 src/stats/main.cs                          |    4 +-
 src/util.cs                                |   51 +----
 src/utilDate.cs                            |   91 +++++++++
 27 files changed, 685 insertions(+), 264 deletions(-)
---
diff --git a/TODO.txt b/TODO.txt
index 1c57ebe..3ea38a1 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,5 +1,7 @@
 TODO: 
 
+autogen should compile chronojump_mini, but if a make clean is done then it compiles it
+
 server menu / Query: do age, put a progressBar when search
 
 updating manual. Pending:
diff --git a/chronojump_server/Makefile.am b/chronojump_server/Makefile.am
index 484f5ca..7663e6e 100644
--- a/chronojump_server/Makefile.am
+++ b/chronojump_server/Makefile.am
@@ -23,6 +23,7 @@ FILES = \
 	BCrypt.cs\
 	../src/sqlite/*.cs\
 	../src/util.cs\
+	../src/utilDate.cs\
 	../src/person.cs\
 	../src/event.cs\
 	../src/jump.cs\
diff --git a/chronojump_server/bin/chronojumpServer.dll b/chronojump_server/bin/chronojumpServer.dll
index 928a1e6..8269434 100755
Binary files a/chronojump_server/bin/chronojumpServer.dll and b/chronojump_server/bin/chronojumpServer.dll differ
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index cf35ae0..831e2c0 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -29455,6 +29455,8 @@ by you</property>
 		  <child>
 		    <widget class="GtkHBox" id="hbox_combo_test_types">
 		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="has_focus">True</property>
 		      <property name="homogeneous">False</property>
 		      <property name="spacing">0</property>
 
@@ -29651,7 +29653,7 @@ by you</property>
 	      <child>
 		<widget class="GtkTable" id="table70">
 		  <property name="visible">True</property>
-		  <property name="n_rows">7</property>
+		  <property name="n_rows">9</property>
 		  <property name="n_columns">3</property>
 		  <property name="homogeneous">False</property>
 		  <property name="row_spacing">4</property>
@@ -29686,34 +29688,6 @@ by you</property>
 		  </child>
 
 		  <child>
-		    <widget class="GtkLabel" id="label_age">
-		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">Age</property>
-		      <property name="use_underline">False</property>
-		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_LEFT</property>
-		      <property name="wrap">False</property>
-		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
-		      <property name="yalign">0.5</property>
-		      <property name="xpad">0</property>
-		      <property name="ypad">0</property>
-		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		      <property name="width_chars">-1</property>
-		      <property name="single_line_mode">False</property>
-		      <property name="angle">0</property>
-		    </widget>
-		    <packing>
-		      <property name="left_attach">1</property>
-		      <property name="right_attach">2</property>
-		      <property name="top_attach">1</property>
-		      <property name="bottom_attach">2</property>
-		      <property name="x_options">fill</property>
-		      <property name="y_options"></property>
-		    </packing>
-		  </child>
-
-		  <child>
 		    <widget class="GtkLabel" id="label_country">
 		      <property name="visible">True</property>
 		      <property name="label" translatable="yes">Country</property>
@@ -29734,8 +29708,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">1</property>
 		      <property name="right_attach">2</property>
-		      <property name="top_attach">3</property>
-		      <property name="bottom_attach">4</property>
+		      <property name="top_attach">5</property>
+		      <property name="bottom_attach">6</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options"></property>
 		    </packing>
@@ -29762,8 +29736,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">1</property>
 		      <property name="right_attach">2</property>
-		      <property name="top_attach">4</property>
-		      <property name="bottom_attach">5</property>
+		      <property name="top_attach">6</property>
+		      <property name="bottom_attach">7</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options"></property>
 		    </packing>
@@ -29790,8 +29764,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">1</property>
 		      <property name="right_attach">2</property>
-		      <property name="top_attach">6</property>
-		      <property name="bottom_attach">7</property>
+		      <property name="top_attach">8</property>
+		      <property name="bottom_attach">9</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options"></property>
 		    </packing>
@@ -29818,8 +29792,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">1</property>
 		      <property name="right_attach">2</property>
-		      <property name="top_attach">5</property>
-		      <property name="bottom_attach">6</property>
+		      <property name="top_attach">7</property>
+		      <property name="bottom_attach">8</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options"></property>
 		    </packing>
@@ -29846,10 +29820,22 @@ by you</property>
 		  </child>
 
 		  <child>
-		    <widget class="GtkHBox" id="hbox_combo_ages">
+		    <widget class="GtkHBox" id="hbox_ages">
 		      <property name="visible">True</property>
 		      <property name="homogeneous">False</property>
-		      <property name="spacing">0</property>
+		      <property name="spacing">4</property>
+
+		      <child>
+			<placeholder/>
+		      </child>
+
+		      <child>
+			<placeholder/>
+		      </child>
+
+		      <child>
+			<placeholder/>
+		      </child>
 
 		      <child>
 			<placeholder/>
@@ -29858,8 +29844,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">2</property>
 		      <property name="right_attach">3</property>
-		      <property name="top_attach">1</property>
-		      <property name="bottom_attach">2</property>
+		      <property name="top_attach">2</property>
+		      <property name="bottom_attach">3</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
@@ -29878,8 +29864,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">2</property>
 		      <property name="right_attach">3</property>
-		      <property name="top_attach">3</property>
-		      <property name="bottom_attach">4</property>
+		      <property name="top_attach">5</property>
+		      <property name="bottom_attach">6</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
@@ -29898,8 +29884,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">2</property>
 		      <property name="right_attach">3</property>
-		      <property name="top_attach">4</property>
-		      <property name="bottom_attach">5</property>
+		      <property name="top_attach">6</property>
+		      <property name="bottom_attach">7</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
@@ -29918,8 +29904,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">2</property>
 		      <property name="right_attach">3</property>
-		      <property name="top_attach">5</property>
-		      <property name="bottom_attach">6</property>
+		      <property name="top_attach">7</property>
+		      <property name="bottom_attach">8</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
@@ -29938,8 +29924,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">2</property>
 		      <property name="right_attach">3</property>
-		      <property name="top_attach">6</property>
-		      <property name="bottom_attach">7</property>
+		      <property name="top_attach">8</property>
+		      <property name="bottom_attach">9</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
@@ -29966,8 +29952,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">1</property>
 		      <property name="right_attach">2</property>
-		      <property name="top_attach">2</property>
-		      <property name="bottom_attach">3</property>
+		      <property name="top_attach">4</property>
+		      <property name="bottom_attach">5</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options"></property>
 		    </packing>
@@ -29986,8 +29972,8 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">2</property>
 		      <property name="right_attach">3</property>
-		      <property name="top_attach">2</property>
-		      <property name="bottom_attach">3</property>
+		      <property name="top_attach">4</property>
+		      <property name="bottom_attach">5</property>
 		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
@@ -30006,12 +29992,195 @@ by you</property>
 		    <packing>
 		      <property name="left_attach">0</property>
 		      <property name="right_attach">1</property>
+		      <property name="top_attach">5</property>
+		      <property name="bottom_attach">6</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options">fill</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox_ages2">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">4</property>
+
+		      <child>
+			<placeholder/>
+		      </child>
+
+		      <child>
+			<placeholder/>
+		      </child>
+
+		      <child>
+			<placeholder/>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">2</property>
+		      <property name="right_attach">3</property>
 		      <property name="top_attach">3</property>
 		      <property name="bottom_attach">4</property>
 		      <property name="x_options">fill</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkTable" id="table73">
+		      <property name="visible">True</property>
+		      <property name="n_rows">2</property>
+		      <property name="n_columns">3</property>
+		      <property name="homogeneous">False</property>
+		      <property name="row_spacing">0</property>
+		      <property name="column_spacing">6</property>
+
+		      <child>
+			<widget class="GtkSpinButton" id="spin_ages1">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="climb_rate">1</property>
+			  <property name="digits">0</property>
+			  <property name="numeric">True</property>
+			  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+			  <property name="snap_to_ticks">True</property>
+			  <property name="wrap">False</property>
+			  <property name="adjustment">1 1 100 1 10 10</property>
+			</widget>
+			<packing>
+			  <property name="left_attach">2</property>
+			  <property name="right_attach">3</property>
+			  <property name="top_attach">0</property>
+			  <property name="bottom_attach">1</property>
+			  <property name="y_options"></property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkSpinButton" id="spin_ages2">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="climb_rate">1</property>
+			  <property name="digits">0</property>
+			  <property name="numeric">True</property>
+			  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+			  <property name="snap_to_ticks">True</property>
+			  <property name="wrap">False</property>
+			  <property name="adjustment">1 1 100 1 10 10</property>
+			</widget>
+			<packing>
+			  <property name="left_attach">2</property>
+			  <property name="right_attach">3</property>
+			  <property name="top_attach">1</property>
+			  <property name="bottom_attach">2</property>
+			  <property name="y_options"></property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkHBox" id="hbox_combo_ages1">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">0</property>
+
+			  <child>
+			    <placeholder/>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="left_attach">1</property>
+			  <property name="right_attach">2</property>
+			  <property name="top_attach">0</property>
+			  <property name="bottom_attach">1</property>
+			  <property name="y_options">fill</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkHBox" id="hbox_combo_ages2">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">0</property>
+
+			  <child>
+			    <placeholder/>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="left_attach">1</property>
+			  <property name="right_attach">2</property>
+			  <property name="top_attach">1</property>
+			  <property name="bottom_attach">2</property>
+			  <property name="x_options">fill</property>
+			  <property name="y_options">fill</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkLabel" id="label_age_and">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">And</property>
+			  <property name="use_underline">False</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			</widget>
+			<packing>
+			  <property name="left_attach">0</property>
+			  <property name="right_attach">1</property>
+			  <property name="top_attach">1</property>
+			  <property name="bottom_attach">2</property>
+			  <property name="x_options">fill</property>
+			  <property name="y_options"></property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">2</property>
+		      <property name="right_attach">3</property>
+		      <property name="top_attach">1</property>
+		      <property name="bottom_attach">2</property>
+		      <property name="x_options">fill</property>
 		      <property name="y_options">fill</property>
 		    </packing>
 		  </child>
+
+		  <child>
+		    <widget class="GtkLabel" id="label_age">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Age</property>
+		      <property name="use_underline">False</property>
+		      <property name="use_markup">False</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
+		      <property name="wrap">False</property>
+		      <property name="selectable">False</property>
+		      <property name="xalign">0</property>
+		      <property name="yalign">0</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		      <property name="width_chars">-1</property>
+		      <property name="single_line_mode">False</property>
+		      <property name="angle">0</property>
+		    </widget>
+		    <packing>
+		      <property name="left_attach">1</property>
+		      <property name="right_attach">2</property>
+		      <property name="top_attach">1</property>
+		      <property name="bottom_attach">2</property>
+		      <property name="x_options">fill</property>
+		      <property name="y_options"></property>
+		    </packing>
+		  </child>
 		</widget>
 	      </child>
 	    </widget>
@@ -30074,10 +30243,11 @@ by you</property>
 
 		  <child>
 		    <widget class="GtkScrolledWindow" id="scrolledwindow37">
+		      <property name="height_request">36</property>
 		      <property name="visible">True</property>
 		      <property name="can_focus">True</property>
-		      <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
-		      <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+		      <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+		      <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
 		      <property name="shadow_type">GTK_SHADOW_IN</property>
 		      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
 
@@ -30109,9 +30279,9 @@ by you</property>
 		  </child>
 
 		  <child>
-		    <widget class="GtkHBox" id="hbox364">
+		    <widget class="GtkHBox" id="hbox368">
 		      <property name="visible">True</property>
-		      <property name="homogeneous">False</property>
+		      <property name="homogeneous">True</property>
 		      <property name="spacing">8</property>
 
 		      <child>
@@ -30127,8 +30297,8 @@ by you</property>
 			</widget>
 			<packing>
 			  <property name="padding">0</property>
-			  <property name="expand">False</property>
-			  <property name="fill">False</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
 			</packing>
 		      </child>
 
diff --git a/src/Makefile.am b/src/Makefile.am
index bf8d1e0..6793e2e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -176,6 +176,7 @@ FILES = \
  	treeViewReactionTime.cs\
  	treeViewMultiChronopic.cs\
  	util.cs\
+ 	utilDate.cs\
 	utilGtk.cs\
 	constants.cs\
  	report.cs\
@@ -317,7 +318,8 @@ DLL_REFERENCES =  \
 	../build/data/linux_dlls/NPlot.Gtk.dll
 
 
-CLEANFILES = $(COMMONAPPLICATIONDATA_ROOT) $(COMMONAPPLICATIONDATAROOT_IMAGES) $(COMMONAPPLICATIONDATAROOT_LOGO) $(PROGRAMFILES) $(LINUX_DESKTOPAPPLICATIONS) $(BINARIES) 
+#CLEANFILES = $(COMMONAPPLICATIONDATA_ROOT) $(COMMONAPPLICATIONDATAROOT_IMAGES) $(COMMONAPPLICATIONDATAROOT_LOGO) $(PROGRAMFILES) $(LINUX_DESKTOPAPPLICATIONS) $(BINARIES) 
+CLEANFILES = $(PROGRAMFILES) $(LINUX_DESKTOPAPPLICATIONS) $(BINARIES) 
 
 
 include $(top_srcdir)/Makefile.include
diff --git a/src/chronojump_mini.cs b/src/chronojump_mini.cs
index 1df5ac2..aa9822f 100644
--- a/src/chronojump_mini.cs
+++ b/src/chronojump_mini.cs
@@ -39,7 +39,9 @@ class Test {
 		string portName = "";
 		string fileName = "";
 		TextWriter writer;
-		string defaultFileName = "output.txt"; //always output to a file, but if not specified, output here and rewrite it every chronojump_mini execution
+		
+		//always output to a file, but if not specified, output here and rewrite it every chronojump_mini execution
+		string defaultFileName = Path.Combine(getOutputDir(), "output"); 
 	       
 
 		System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("es-ES");
@@ -59,19 +61,13 @@ class Test {
 					portName = args[i].Substring(5);
 				else if (args[i].StartsWith("FILE=")) {
 					fileName = args[i].Substring(5);
-					//put file in windows or linux folder (instead of data folder)
-					fileName=".." + Path.DirectorySeparatorChar + getOutputDir() + Path.DirectorySeparatorChar + fileName;
+					fileName= getOutputDir() + Path.DirectorySeparatorChar + fileName;
 				}
 				else
 					printSyntaxAndQuit();
 			}
 		}
 		
-		//output file stuff
-		fileName = manageFileName(fileName, defaultFileName);
-		writer = File.CreateText(fileName);
-				
-
 		//detection of ports
 		string messageInfo;
 		//string messageDetected ="";
@@ -89,19 +85,13 @@ class Test {
 			*/
 		} else {
 			messageInfo = Constants.PortNamesLinux;
-
-			//messageDetected = string.Format(Catalog.GetString("Auto-Detection currently disabled on GNU/Linux"));
 		}
 			
 		messageInfo += string.Format("\n" + Catalog.GetString("More information on Chronojump manual"));
 
-		//messageDetected = string.Format(Catalog.GetString("Auto-Detection currently disabled"));
-
 		Console.WriteLine("---------------------------");
 		Console.WriteLine(messageInfo);
 		Console.WriteLine("---------------------------");
-		//Console.WriteLine(messageDetected);
-		Console.WriteLine("---------------------------\n");
 
 		if(portName == "") {
 			if( ! Util.IsWindows()) {
@@ -111,6 +101,14 @@ class Test {
 			portName=Console.ReadLine();
 		}
 
+		//output file stuff
+		fileName = manageFileName(fileName);
+		if(fileName == "") 
+			fileName = defaultFileName + "-" + portName.Replace("/","") + ".csv";
+		
+		writer = File.CreateText(fileName);
+		
+
 		Console.WriteLine(Catalog.GetString("Opening port...") + " " +
 			       Catalog.GetString("Please touch the platform or click Chronopic TEST button"));
 		//-- Crear puerto serie		
@@ -126,6 +124,8 @@ class Test {
 			Console.WriteLine(e);
 			Environment.Exit(1);
 		}
+		
+
 
 		//-- Crear objeto chronopic, para acceder al chronopic
 		Chronopic cp = new Chronopic(sp);
@@ -169,8 +169,8 @@ class Test {
 						
 		Console.WriteLine("  TC(ms) TF(ms)");
 		writer.WriteLine("count;TC(ms);TF(ms)");
-		while(true) {
 
+		while(true) {
 			//-- Esperar a que llegue una trama
 			do {
 				ok = cp.Read_event(out timestamp, out estado_plataforma);
@@ -244,7 +244,7 @@ class Test {
 		Environment.Exit(1);
 	}
 
-	static string manageFileName(string fileName, string defaultFileName) {
+	static string manageFileName(string fileName) {
 		bool fileOk = false;
 		do {
 			if(fileName == "") 
@@ -267,17 +267,11 @@ class Test {
 			}
 		} while(! fileOk);
 
-		if(fileName == "") 
-			fileName = defaultFileName;
-
 		return fileName;
 	}
 
 	static string getOutputDir() {
-		string dir = "linux";
-		if(Util.IsWindows())
-			dir = "windows";
-		return dir;
+		return Util.GetApplicationDataDir();
 	}
 
 	static string getFileName() {
@@ -287,12 +281,10 @@ class Test {
 
 		if(option == "Y" || option == "y") {
 			Console.WriteLine(Catalog.GetString("If you want to open it with an Spreadsheet like Gnumeric, OpenOffice or MS Office, we recomend to use .csv extension.\neg: 'test.csv'"));
-			Console.WriteLine(string.Format(Catalog.GetString("File will be available at directory: {0}"), Path.GetFullPath(".." + Path.DirectorySeparatorChar + getOutputDir())));
+			Console.WriteLine(string.Format(Catalog.GetString("File will be available at directory: {0}"), getOutputDir()));
 			Console.WriteLine(Catalog.GetString("Please, write filename:"));
 			fileName=Console.ReadLine();
-
-			//put file in windows or linux folder (instead of data folder)
-			fileName=".." + Path.DirectorySeparatorChar + getOutputDir() + Path.DirectorySeparatorChar + fileName;
+			fileName= getOutputDir() + Path.DirectorySeparatorChar + fileName;
 		}
 		//if 'n' then "" will be returned
 
diff --git a/src/gui/dialogCalendar.cs b/src/gui/dialogCalendar.cs
index d75c614..7255245 100644
--- a/src/gui/dialogCalendar.cs
+++ b/src/gui/dialogCalendar.cs
@@ -32,7 +32,7 @@ public class DialogCalendar
 	//for raise a signal and manage it on guis/session.cs (and other places)
 	protected Gtk.Button fakeButtonDateChanged;
 
-	public DialogCalendar (string calendarTitle)
+	public DialogCalendar (string calendarTitle, DateTime dateInitial)
 	{
 		Glade.XML gladeXML;
 		gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", "dialog_calendar", null);
@@ -43,18 +43,26 @@ public class DialogCalendar
 		
 		dialog_calendar.Title = calendarTitle; 
 
+		calendar1.Date = dateInitial;
+
 		fakeButtonDateChanged = new Button();
 	}
 				
 	void on_calendar1_day_selected (object obj, EventArgs args)
 	{
-		Calendar activatedCalendar = (Calendar) obj;
-
-		//Log.WriteLine ( activatedCalendar.GetDate().ToLongDateString());
-		myDateTime = activatedCalendar.Date;
+		try {
+			Calendar activatedCalendar = (Calendar) obj;
+			myDateTime = activatedCalendar.Date;
 
-		//raise a signal
-		fakeButtonDateChanged.Click();
+			//raise a signal
+			fakeButtonDateChanged.Click();
+		}
+		catch {
+			/* 
+			   when dialog starts, calendar1.Date = dateInitial changes date
+			   and raises this and it's too early
+			   */
+		}
 	}
 
 
diff --git a/src/gui/dialogServerStats.cs b/src/gui/dialogServerStats.cs
index 3b811e0..cf1483b 100644
--- a/src/gui/dialogServerStats.cs
+++ b/src/gui/dialogServerStats.cs
@@ -136,7 +136,7 @@ public class DialogServerStats
 			}
 		}
 		
-		label_date.Text = Util.DateParse(DateTime.Now.ToString());
+		label_date.Text = DateTime.Now.ToString();
 	}
 
 
diff --git a/src/gui/evaluator.cs b/src/gui/evaluator.cs
index b96b5b5..e7f7095 100644
--- a/src/gui/evaluator.cs
+++ b/src/gui/evaluator.cs
@@ -116,7 +116,6 @@ public class EvaluatorWindow
 			creating = true;
 		
 		//copy to see if there are changes
-		//evalBefore = eval;
 		evalBefore = new ServerEvaluator(eval);
 		
 		createComboContinents();
@@ -340,7 +339,7 @@ public class EvaluatorWindow
 
 	void on_button_change_date_clicked (object o, EventArgs args)
 	{
-		myDialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"));
+		myDialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"), dateTime);
 		myDialogCalendar.FakeButtonDateChanged.Clicked += new EventHandler(on_calendar_changed);
 	}
 
@@ -360,7 +359,7 @@ public class EvaluatorWindow
 		if(creating)
 			label_date.Text = Catalog.GetString(Constants.UndefinedDefault);
 		else {
-			dateTime = Util.DateAsDateTime(eval.DateBorn);
+			dateTime = eval.DateBorn;
 			if(dateTime == DateTime.MinValue)
 				label_date.Text = Catalog.GetString(Constants.UndefinedDefault);
 			else
@@ -445,11 +444,7 @@ public class EvaluatorWindow
 	{
 		eval.Name = entry_name.Text.ToString();
 		eval.Email = entry_email.Text.ToString();
-		
-		string dateFull = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" +
-			dateTime.Year.ToString();
-		eval.DateBorn = dateFull;
-
+		eval.DateBorn = dateTime;
 		eval.CountryID = Convert.ToInt32(
 				Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries));
 
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 9a325c6..fd3bc8a 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -117,7 +117,7 @@ public class PersonRecuperateWindow {
 		store.SetSortFunc (firstColumn + 0, UtilGtk.IdColumnCompare);
 		store.SetSortFunc (firstColumn + 3, heightColumnCompare);
 		store.SetSortFunc (firstColumn + 4, weightColumnCompare);
-		store.SetSortFunc (firstColumn + 5, birthColumnCompare);
+		//store.SetSortFunc (firstColumn + 5, birthColumnCompare);
 	}
 	
 	public int heightColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2)     {
@@ -138,14 +138,16 @@ public class PersonRecuperateWindow {
 		return (val1-val2);
 	}
 
+	/*
 	public int birthColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2)     {
 		DateTime val1; 
 		DateTime val2; 
-		val1 = Util.DateAsDateTime(model.GetValue(iter1, firstColumn + 5).ToString());
-		val2 = Util.DateAsDateTime(model.GetValue(iter2, firstColumn + 5).ToString());
+		val1 = UtilDate.DateAsDateTime(model.GetValue(iter1, firstColumn + 5).ToString());
+		val2 = UtilDate.DateAsDateTime(model.GetValue(iter2, firstColumn + 5).ToString());
 		
 		return DateTime.Compare(val1, val2);
 	}
+	*/
 
 	private void fillTreeView (Gtk.TreeView tv, TreeStore store, string searchFilterName) {
 		string [] myPersons;
@@ -1080,7 +1082,6 @@ public class PersonAddModifyWindow
 		int mySpeciallityID;
 		int myLevelID;
 		if(adding) {
-			//dateTime = DateTime.Today;
 			//now dateTime is undefined until user changes it
 			dateTime = DateTime.MinValue;
 			label_date.Text = Catalog.GetString("Undefined");
@@ -1098,12 +1099,13 @@ public class PersonAddModifyWindow
 				radiobutton_woman.Active = true;
 			}
 
-			dateTime = Util.DateAsDateTime(myPerson.DateBorn);
+			dateTime = myPerson.DateBorn;
 			if(dateTime == DateTime.MinValue)
 				label_date.Text = Catalog.GetString("Undefined");
 			else
 				label_date.Text = dateTime.ToLongDateString();
 
+
 			spinbutton_height.Value = myPerson.Height;
 			spinbutton_weight.Value = myPerson.Weight;
 			weightIni = myPerson.Weight; //store for tracking if changes
@@ -1155,7 +1157,10 @@ public class PersonAddModifyWindow
 	
 	void on_button_calendar_clicked (object o, EventArgs args)
 	{
-		myDialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"));
+		DateTime dt = dateTime;
+		if(dt == DateTime.MinValue)
+			dt = DateTime.Now;
+		myDialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"), dt);
 		myDialogCalendar.FakeButtonDateChanged.Clicked += new EventHandler(on_calendar_changed);
 	}
 
@@ -1401,8 +1406,8 @@ public class PersonAddModifyWindow
 
 	private void recordChanges() {
 		//separate by '/' for not confusing with the ':' separation between the other values
-		string dateFull = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" +
-			dateTime.Year.ToString();
+		//string dateFull = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" +
+		//	dateTime.Year.ToString();
 		
 		double weight = (int) spinbutton_weight.Value;
 
@@ -1418,7 +1423,8 @@ public class PersonAddModifyWindow
 
 
 		if(adding) {
-			currentPerson = new Person (entry1.Text, sex, dateFull, 
+			//currentPerson = new Person (entry1.Text, sex, dateFull, 
+			currentPerson = new Person (entry1.Text, sex, dateTime, 
 					(int) spinbutton_height.Value, (int) weight, 
 					sport.UniqueID, 
 					Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities)),
@@ -1429,7 +1435,8 @@ public class PersonAddModifyWindow
 					Constants.ServerUndefinedID,
 					currentSession.UniqueID);
 		} else {
-			currentPerson = new Person (personID, entry1.Text, sex, dateFull, 
+			//currentPerson = new Person (personID, entry1.Text, sex, dateFull, 
+			currentPerson = new Person (personID, entry1.Text, sex, dateTime, 
 					(int) spinbutton_height.Value, (int) weight, 
 					sport.UniqueID, 
 					Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities)),
@@ -1700,12 +1707,10 @@ public class PersonAddMultipleWindow {
 		string sex = Constants.F;
 		if(male) { sex = Constants.M; }
 
-		//DateTime dateTime = DateTime.Today;
 		//now dateTime is undefined until user changes it
 		DateTime dateTime = DateTime.MinValue;
-		string dateFull = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" + dateTime.Year.ToString();
 
-		currentPerson = new Person ( name, sex, dateFull, 
+		currentPerson = new Person ( name, sex, dateTime, 
 				0, weight, 		//height, weight	
 				currentSession.PersonsSportID,
 				currentSession.PersonsSpeciallityID,
diff --git a/src/gui/queryServer.cs b/src/gui/queryServer.cs
index 9e71963..fc8d390 100644
--- a/src/gui/queryServer.cs
+++ b/src/gui/queryServer.cs
@@ -34,7 +34,8 @@ public class QueryServerWindow
 	[Widget] Gtk.Box hbox_combo_tests;
 	[Widget] Gtk.Box hbox_combo_variables;
 	[Widget] Gtk.Box hbox_combo_sexes;
-	//[Widget] Gtk.Box hbox_combo_ages;
+	[Widget] Gtk.Box hbox_combo_ages1;
+	[Widget] Gtk.Box hbox_combo_ages2;
 	[Widget] Gtk.Box hbox_combo_continents;
 	[Widget] Gtk.Box hbox_combo_countries;
 	[Widget] Gtk.Box hbox_combo_sports;
@@ -45,7 +46,8 @@ public class QueryServerWindow
 	[Widget] Gtk.ComboBox combo_tests;
 	[Widget] Gtk.ComboBox combo_variables;
 	[Widget] Gtk.ComboBox combo_sexes;
-	//[Widget] Gtk.ComboBox combo_ages;
+	[Widget] Gtk.ComboBox combo_ages1;
+	[Widget] Gtk.ComboBox combo_ages2;
 	[Widget] Gtk.ComboBox combo_continents;
 	[Widget] Gtk.ComboBox combo_countries;
 	[Widget] Gtk.ComboBox combo_sports;
@@ -54,7 +56,9 @@ public class QueryServerWindow
 
 	[Widget] Gtk.TextView textview_query;
 	
-	[Widget] Gtk.Label label_age;
+	[Widget] Gtk.Label label_age_and;
+	[Widget] Gtk.SpinButton spin_ages1;
+	[Widget] Gtk.SpinButton spin_ages2;
 	[Widget] Gtk.Label label_speciallity;
 	[Widget] Gtk.Label label_results_num;
 	[Widget] Gtk.Label label_results_avg;
@@ -111,6 +115,32 @@ public class QueryServerWindow
 		Catalog.GetString(Constants.Females), 
 	};
 
+
+	static string equalThan = "=  " + Catalog.GetString("Equal than");
+	static string lowerThan = "<  " + Catalog.GetString("Lower than");
+	static string higherThan = ">  " + Catalog.GetString("Higher than");
+	static string lowerOrEqualThan = "<= " + Catalog.GetString("Lower or equal than");
+	static string higherOrEqualThan = ">= " + Catalog.GetString("Higher or equal than");
+	string [] ages1 = {
+		Catalog.GetString(Constants.Any), 
+		equalThan,
+		lowerThan,
+		higherThan,
+		lowerOrEqualThan,
+		higherOrEqualThan,
+	};
+	string [] ages2Lower = {
+		Catalog.GetString(Constants.Any), 
+		lowerThan,
+		lowerOrEqualThan,
+	};
+	string [] ages2Higher = {
+		Catalog.GetString(Constants.Any), 
+		higherThan,
+		higherOrEqualThan,
+	};
+
+
 	Sport sport;
 	string [] sports;
 	string [] sportsTranslated;
@@ -161,11 +191,10 @@ public class QueryServerWindow
 		createComboContinents();
 		createComboCountries();
 		createComboSexes();
-		//createComboAges();
-		
+		createComboAges1();
+		createComboAges2();
 		createComboSports();
 		createComboSpeciallities(-1);
-		
 		createComboLevels();
 	}
 	
@@ -240,7 +269,25 @@ public class QueryServerWindow
 		UtilGtk.ComboPackShowAndSensitive(hbox_combo_sexes, combo_sexes);
 	}
 
-	private void createComboAges() {
+	private void createComboAges1() {
+		combo_ages1 = ComboBox.NewText ();
+		UtilGtk.ComboUpdate(combo_ages1, ages1, "");
+		combo_ages1.Active = UtilGtk.ComboMakeActive(ages1, Catalog.GetString(Constants.Any));
+		combo_ages1.Changed += new EventHandler (on_combo_ages1_changed);
+		UtilGtk.ComboPackShowAndSensitive(hbox_combo_ages1, combo_ages1);
+		spin_ages1.Sensitive = false;
+		label_age_and.Sensitive = false;
+	}
+
+	private void createComboAges2() {
+		combo_ages2 = ComboBox.NewText ();
+		string [] ages2 = Util.StringToStringArray(Constants.Any);
+		UtilGtk.ComboUpdate(combo_ages2, ages2, "");
+		combo_ages2.Active = UtilGtk.ComboMakeActive(ages2, Catalog.GetString(Constants.Any));
+		combo_ages2.Changed += new EventHandler (on_combo_ages2_changed);
+		UtilGtk.ComboPackShowAndSensitive(hbox_combo_ages2, combo_ages2);
+		combo_ages2.Sensitive = false;
+		spin_ages2.Sensitive = false;
 	}
 
 	private void createComboSports() {
@@ -404,6 +451,52 @@ public class QueryServerWindow
 
 		on_entries_required_changed(new object(), new EventArgs());
 	}
+	
+	private void on_combo_ages1_changed(object o, EventArgs args) 
+	{
+		string age1 = UtilGtk.ComboGetActive(combo_ages1);
+		string [] ages2;
+
+		if (age1 == Catalog.GetString(Constants.Any) ||	age1 == equalThan) {
+			if (age1 == Catalog.GetString(Constants.Any))  //zero values
+				spin_ages1.Sensitive = false;
+			else
+				spin_ages1.Sensitive = true;
+			
+			//no value 2
+			label_age_and.Sensitive = false;
+			combo_ages2.Sensitive = false;
+			spin_ages2.Sensitive = false;
+
+			ages2 = Util.StringToStringArray(Constants.Any);
+		} else {
+			spin_ages1.Sensitive = true;
+			label_age_and.Sensitive = true;
+			combo_ages2.Sensitive = true;
+			spin_ages2.Sensitive = true;
+			if (age1 == lowerThan || age1 == lowerOrEqualThan)
+				ages2 = ages2Higher;
+			else
+				ages2 = ages2Lower;
+		}
+	
+		UtilGtk.ComboUpdate(combo_ages2, ages2, "");
+		combo_ages2.Active = UtilGtk.ComboMakeActive(ages2, Catalog.GetString(Constants.Any));
+	
+		on_entries_required_changed(new object(), new EventArgs());
+	}
+
+	private void on_combo_ages2_changed(object o, EventArgs args) 
+	{
+		string age2 = UtilGtk.ComboGetActive(combo_ages2);
+
+		if (age2 == Catalog.GetString(Constants.Any)) 
+			spin_ages2.Sensitive = false;
+		else 
+			spin_ages2.Sensitive = true;
+	
+		on_entries_required_changed(new object(), new EventArgs());
+	}
 
 	private void on_combo_sports_changed(object o, EventArgs args) {
 		ComboBox combo = o as ComboBox;
@@ -616,7 +709,6 @@ public class QueryServerWindow
 		combo_variables.Sensitive = false;
 		label_speciallity.Hide();
 		combo_speciallities.Hide();
-		label_age.Hide(); //currently no age support
 		
 		on_entries_required_changed(new object(), new EventArgs());
 	}
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 29da87d..8360117 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -111,7 +111,7 @@ public class SessionAddEditWindow {
 		} else {
 			session_add_edit.Title = Catalog.GetString("Session Edit");
 
-			dateTime = Util.DateAsDateTime(currentSession.Date);
+			dateTime = currentSession.Date;
 
 			entry_name.Text = currentSession.Name;
 			entry_place.Text = currentSession.Place;
@@ -511,7 +511,7 @@ public class SessionAddEditWindow {
 	
 	void on_button_change_date_clicked (object o, EventArgs args)
 	{
-		myDialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"));
+		myDialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"), dateTime);
 		myDialogCalendar.FakeButtonDateChanged.Clicked += new EventHandler(on_calendar_changed);
 	}
 
@@ -563,9 +563,6 @@ public class SessionAddEditWindow {
 	
 	void on_button_accept_clicked (object o, EventArgs args)
 	{
-		string myDate = dateTime.Day.ToString() + "/" + dateTime.Month.ToString() + "/" +
-			dateTime.Year.ToString();
-		
 		//check if name of session exists (is owned by other session),
 		//but all is ok if the name is the same as the old name (editing)
 		bool sessionNameExists = Sqlite.Exists (Constants.SessionTable, Util.RemoveTildeAndColon(entry_name.Text));
@@ -577,8 +574,6 @@ public class SessionAddEditWindow {
 			if(radiobutton_diff_sports.Active)
 				sportID = Constants.SportUndefinedID;
 			else {
-//				Sport mySport = new Sport(UtilGtk.ComboGetActive(combo_sports));
-//				sportID = mySport.UniqueID;
 				sportID = Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_sports), sports));
 			}
 
@@ -586,7 +581,6 @@ public class SessionAddEditWindow {
 			if(!label_speciallity.Visible || radiobutton_diff_speciallities.Active)
 				speciallityID = Constants.SpeciallityUndefinedID; 
 			else
-				//speciallityID = Util.FetchID(UtilGtk.ComboGetActive(combo_speciallities));
 				speciallityID = Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities));
 
 			int levelID;
@@ -596,14 +590,16 @@ public class SessionAddEditWindow {
 				levelID = Util.FetchID(UtilGtk.ComboGetActive(combo_levels));
 
 			if(addSession) 
-				currentSession = new Session (Util.RemoveTildeAndColon(entry_name.Text), Util.RemoveTildeAndColon(entry_place.Text), myDate, 
+				currentSession = new Session (Util.RemoveTildeAndColon(entry_name.Text), 
+						Util.RemoveTildeAndColon(entry_place.Text), 
+						dateTime,
 						sportID, speciallityID, levelID,
 						Util.RemoveTildeAndColon(textview.Buffer.Text),
 						Constants.ServerUndefinedID);
 			else {
 				currentSession.Name = Util.RemoveTildeAndColon(entry_name.Text.ToString());
 				currentSession.Place = Util.RemoveTildeAndColon(entry_place.Text.ToString()); 
-				currentSession.Date = myDate;
+				currentSession.Date = dateTime;
 				currentSession.PersonsSportID = sportID;
 				currentSession.PersonsSpeciallityID = speciallityID;
 				currentSession.PersonsPractice = levelID;
@@ -729,7 +725,7 @@ public class SessionLoadWindow {
 
 			store.AppendValues (myStringFull[0], myStringFull[1], 
 					myStringFull[2], 
-					Util.DateAsDateTime(myStringFull[3]).ToShortDateString(),
+					myStringFull[3],	//session date
 					myStringFull[8],	//number of jumpers x session
 					mySport,		//personsSport
 					mySpeciallity,		//personsSpeciallity
diff --git a/src/log.cs b/src/log.cs
index 329dd6a..85f374c 100644
--- a/src/log.cs
+++ b/src/log.cs
@@ -45,7 +45,7 @@ public class Log
 		if(args.Length == 1) 
 			timeLog = args[0];
 		else {
-			timeLog = Util.DateParse(DateTime.Now.ToString());
+			timeLog = DateTime.Now.ToString();
 			timeLogPassedOk = false;
 		}
 
diff --git a/src/person.cs b/src/person.cs
index f04c46d..cab1df2 100644
--- a/src/person.cs
+++ b/src/person.cs
@@ -27,7 +27,7 @@ public partial class Person {
 
 	private int uniqueID;
 	private string name;
-	private string dateBorn;
+	private DateTime dateBorn;
 	private int height;
 	private int weight;
 	private int sportID;	//1 undefined, 2 none, 3...n other sports (check table sportType)
@@ -45,7 +45,7 @@ public partial class Person {
 	}
 
 	//suitable when we load a person from the database for being the current Person
-	public Person(int uniqueID, string name, string sex, string dateBorn, 
+	public Person(int uniqueID, string name, string sex, DateTime dateBorn, 
 			int height, int weight, int sportID, int speciallityID, int practice, string description,
 		       int race, int countryID, int serverUniqueID	
 			) 
@@ -70,7 +70,7 @@ public partial class Person {
 	}
 	
 	//typical constructor
-	public Person(string name, string sex, string dateBorn, 
+	public Person(string name, string sex, DateTime dateBorn, 
 			int height, int weight, int sportID, int speciallityID, int practice, string description,
 		       int race, int countryID, int serverUniqueID,	
 			int sessionID) 
@@ -93,12 +93,6 @@ public partial class Person {
 		this.sessionID = sessionID;
 
 		//insert in the person table
-		/*
-		uniqueID = SqlitePerson.Insert (false, //dbconOpened
-				Constants.PersonTable, null, name, sex, dateBorn, height, weight, 
-				sportID, speciallityID, practice, description, race, countryID, serverUniqueID);
-		*/
-
 		//when insert as person we don't know uniqueID
 		uniqueID = -1;
 		int insertedID = this.InsertAtDB(false, Constants.PersonTable);
@@ -118,7 +112,7 @@ public partial class Person {
 		this.uniqueID = Convert.ToInt32(myString[0]);
 		this.name = myString[1];
 		this.sex = myString[2];
-		this.dateBorn = myString[3];
+		this.dateBorn = UtilDate.FromSql(myString[3]);
 		this.height = Convert.ToInt32(myString[4]);
 		this.weight = Convert.ToInt32(myString[5]);
 		this.sportID = Convert.ToInt32(myString[6]);
@@ -143,7 +137,7 @@ public partial class Person {
 
 	public override string ToString()
 	{
-		return "[uniqueID: " + uniqueID + "]" + name + ", " + ", " + sex + ", " + dateBorn + ", " + description;
+		return "[uniqueID: " + uniqueID + "]" + name + ", " + ", " + sex + ", " + dateBorn.ToShortDateString() + ", " + description;
 	}
 	
 	public override bool Equals(object evalString)
@@ -167,7 +161,7 @@ public partial class Person {
 		set { sex = value; }
 	}
 	
-	public string DateBorn {
+	public DateTime DateBorn {
 		get { return dateBorn; }
 		set { dateBorn = value; }
 	}
@@ -224,11 +218,11 @@ public partial class Person {
 	}
 	
 	public string DateLong {
-		get { return Util.DateAsDateTime(dateBorn).ToLongDateString(); }
+		get { return dateBorn.ToLongDateString(); }
 	}
 	
 	public string DateShort {
-		get { return Util.DateAsDateTime(dateBorn).ToShortDateString(); }
+		get { return dateBorn.ToShortDateString(); }
 	}
 	
 	
diff --git a/src/server.cs b/src/server.cs
index 08c2107..af37922 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -58,8 +58,7 @@ public class Server
 			int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
 
 			ServerPing myPing = new ServerPing(evalSID, progName + " " + progVersion, Util.GetOS(), 
-					//Constants.IPUnknown, Util.DateParse(DateTime.Now.ToString())); //evaluator, ip, date
-					getIP(), Util.DateParse(DateTime.Now.ToString())); //evaluator, ip, date
+					getIP(), DateTime.Now); //evaluator, ip, date
 			//if !doIsertion nothing will be uploaded,
 			//is ok for uploadPerson to know if server is online
 			string versionAvailable = myServer.UploadPing(myPing, doInsertion);
@@ -166,7 +165,7 @@ public class Server
 			int state = (int) Constants.ServerSessionStates.UPLOADINGSESSION;
 			//create ServerSession based on Session currentSession
 			ServerSession serverSession = new ServerSession(currentSession, evalSID, progName + " " + progVersion, 
-					Util.GetOS(), Util.DateParse(DateTime.Now.ToString()), state); 
+					Util.GetOS(), DateTime.Now, state); 
 
 			//if uploading session for first time
 			if(currentSession.ServerUniqueID == Constants.ServerUndefinedID) 
@@ -191,11 +190,12 @@ public class Server
 			//upload persons (updating also person.serverUniqueID locally)
 			string [] myPersons = SqlitePersonSession.SelectCurrentSession(serverSession.UniqueID, true, false); //onlyIDAndName, not reversed
 			
-			//store in variable for updating progressBar from other thread
-			progressBarPersonsNum = myPersons.Length;
-
 			Constants.UploadCodes uCode;
 			ArrayList notToUpload = SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);
+			
+			//store in variable for updating progressBar from other thread
+			progressBarPersonsNum = myPersons.Length - notToUpload.Count;
+
 			foreach(string personStr in myPersons) {
 				Person person = SqlitePersonSession.PersonSelect(Util.FetchID(personStr), serverSession.UniqueID); 
 
diff --git a/src/serverEvaluator.cs b/src/serverEvaluator.cs
index 76f6445..5fcac7b 100644
--- a/src/serverEvaluator.cs
+++ b/src/serverEvaluator.cs
@@ -30,7 +30,7 @@ public partial class ServerEvaluator
 	private string code;
 	private string name;
 	private string email;
-	private string dateBorn;
+	private DateTime dateBorn;
 	private int countryID;
 	private string chronometer;
 	private string device;
@@ -42,7 +42,7 @@ public partial class ServerEvaluator
 	public ServerEvaluator() {
 	}
 
-	public ServerEvaluator(string code, string name, string email, string dateBorn, int countryID, string chronometer, string device, string comments, bool confiable) {
+	public ServerEvaluator(string code, string name, string email, DateTime dateBorn, int countryID, string chronometer, string device, string comments, bool confiable) {
 		this.code = code;
 		this.name = name;
 		this.email = email;
@@ -97,7 +97,7 @@ public partial class ServerEvaluator
 
 	public override string ToString() {
 		return "ID: " + uniqueID + "; Name: " + name + 
-			"; Email: " + email + "; DateBorn: " + dateBorn +
+			"; Email: " + email + "; DateBorn: " + dateBorn.ToShortDateString() +
 			"; CountryID: " + countryID + "; Confiable: " + confiable;
 	}
 	
@@ -125,7 +125,7 @@ public partial class ServerEvaluator
 		set { email = value; }
 	}
 
-	public string DateBorn {
+	public DateTime DateBorn {
 		get { return dateBorn; }
 		set { dateBorn = value; }
 	}
diff --git a/src/serverPing.cs b/src/serverPing.cs
index fc5fd63..0906896 100644
--- a/src/serverPing.cs
+++ b/src/serverPing.cs
@@ -31,14 +31,14 @@ public partial class ServerPing
 	private string cjVersion;
 	private string osVersion;
 	private string ip;
-	private string date;
+	private DateTime date;
 
 	//only initializing
 	//needed by the webservice
 	public ServerPing() {
 	}
 
-	public ServerPing(int evaluatorID, string cjVersion, string osVersion, string ip, string date) {
+	public ServerPing(int evaluatorID, string cjVersion, string osVersion, string ip, DateTime date) {
 		this.evaluatorID = evaluatorID;
 		this.cjVersion = cjVersion;
 		this.osVersion = osVersion;
@@ -54,7 +54,7 @@ public partial class ServerPing
 	public override string ToString() {
 		return Catalog.GetString("Uploaded") + "\nID: " + uniqueID + "\nEvaluatorID: " + evaluatorID + 
 			"\nChronojump Version: " + cjVersion + "\nOS Version: " + osVersion +
-			"\nIP: " + ip + "\nDate: " + date;
+			"\nIP: " + ip + "\nDate: " + date.ToString();
 	}
 	
 	public int UniqueID {
@@ -86,7 +86,7 @@ public partial class ServerPing
 		set { ip = value; }
 	}
 
-	public string Date {
+	public DateTime Date {
 		get { return date; }
 		set { date = value; }
 	}
diff --git a/src/session.cs b/src/session.cs
index 1e7389d..f0a0498 100644
--- a/src/session.cs
+++ b/src/session.cs
@@ -29,7 +29,7 @@ public partial class Session {
 	
 	protected string name;
 	protected string place;
-	protected string date;
+	protected DateTime date;
 	protected string comments;
 	protected int serverUniqueID; //not on server
 	
@@ -46,7 +46,7 @@ public partial class Session {
 
 	//suitable when we load a session from the database for being the current session. 
 	//With person sport stuff
-	public Session(string newUniqueID, string newName, string newPlace, string newDate, 
+	public Session(string newUniqueID, string newName, string newPlace, DateTime newDate, 
 			int personsSportID, int personsSpeciallityID, int personsPractice,
 			string newComments, int serverUniqueID) 
 	{
@@ -62,7 +62,7 @@ public partial class Session {
 	}
 
 	//typical constructor with personsSport stuff
-	public Session(string newName, string newPlace, string newDate, 
+	public Session(string newName, string newPlace, DateTime newDate, 
 			int personsSportID, int personsSpeciallityID, int personsPractice,
 			string newComments, int serverUniqueID) 
 	{
@@ -99,7 +99,7 @@ public partial class Session {
 		this.uniqueID = Convert.ToInt32(myString[0]);
 		this.name = myString[1];
 		this.place = myString[2];
-		this.date = myString[3];
+		this.date = UtilDate.FromSql(myString[3]);
 		this.personsSportID = Convert.ToInt32(myString[4]);
 		this.personsSpeciallityID = Convert.ToInt32(myString[5]);
 		this.personsPractice = Convert.ToInt32(myString[6]);
@@ -121,7 +121,7 @@ public partial class Session {
 	
 	public override string ToString()
 	{
-		return "[uniqueID: " + uniqueID + "]" + name + ", " + place + ", " + date + ", " + comments;
+		return "[uniqueID: " + uniqueID + "]" + name + ", " + place + ", " + date.ToShortDateString() + ", " + comments;
 	}
 	
 	public override bool Equals(object evalString)
@@ -145,7 +145,7 @@ public partial class Session {
 		set { place = value; } 
 	}
 
-	public string Date {
+	public DateTime Date {
 		get { return date; }
 		set { date = value; }
 	}
@@ -184,11 +184,11 @@ public partial class Session {
 	}
 	
 	public string DateLong {
-		get { return Util.DateAsDateTime(date).ToLongDateString(); }
+		get { return date.ToLongDateString(); }
 	}
 	
 	public string DateShort {
-		get { return Util.DateAsDateTime(date).ToShortDateString(); }
+		get { return date.ToShortDateString(); }
 	}
 	
 	
@@ -202,16 +202,14 @@ public partial class ServerSession : Session
 	int evaluatorID;
 	string evaluatorCJVersion;
 	string evaluatorOS;
-	string uploadedDate;
-	//Constants.ServerSessionStates uploadingState;
+	DateTime uploadedDate;
 	int uploadingState;
 
 	public ServerSession() {
 	}
 	
 	public ServerSession(Session mySession, int evaluatorID, string evaluatorCJVersion, 
-			//string evaluatorOS, string uploadedDate, Constants.ServerSessionStates uploadingState)
-			string evaluatorOS, string uploadedDate, int uploadingState)
+			string evaluatorOS, DateTime uploadedDate, int uploadingState)
 	{
 		uniqueID = mySession.UniqueID;
 		name = mySession.Name;
@@ -249,9 +247,9 @@ public partial class ServerSession : Session
 	
 	public override string ToString()
 	{
-		return "[" + uniqueID + "]" + name + ", " + place + ", " + date + ", " + 
+		return "[" + uniqueID + "]" + name + ", " + place + ", " + date.ToShortDateString() + ", " + 
 			comments + ",(" + serverUniqueID + "), /" + evaluatorID + "/, " + 
-			evaluatorCJVersion + ", " + evaluatorOS + ", " + uploadedDate + ", " + uploadingState;
+			evaluatorCJVersion + ", " + evaluatorOS + ", " + uploadedDate.ToString() + ", " + uploadingState;
 	}
 	
 	public int EvaluatorID {
@@ -269,7 +267,7 @@ public partial class ServerSession : Session
 		set { evaluatorOS = value; }
 	}
 
-	public string UploadedDate {
+	public DateTime UploadedDate {
 		get { return uploadedDate; }
 		set { uploadedDate = value; }
 	}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index c0cf7c0..e93c414 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -72,7 +72,7 @@ class Sqlite
 	 * Important, change this if there's any update to database
 	 * Important2: if database version get numbers higher than 1, check if the comparisons with currentVersion works ok
 	 */
-	static string lastChronojumpDatabaseVersion = "0.71";
+	static string lastChronojumpDatabaseVersion = "0.72";
 
 	public Sqlite() {
 	}
@@ -937,6 +937,17 @@ Log.WriteLine("home is: " + home);
 				dbcon.Close();
 				currentVersion = "0.71";
 			}
+			if(currentVersion == "0.71") {
+				dbcon.Open();
+				
+				datesToYYYYMMDD();
+
+				SqlitePreferences.Update ("databaseVersion", "0.72", true); 
+				
+				Log.WriteLine("Converted DB to 0.72 (dates to YYYY-MM-DD)"); 
+				dbcon.Close();
+				currentVersion = "0.72";
+			}
 
 
 		}
@@ -1062,6 +1073,7 @@ Log.WriteLine("home is: " + home);
 		SqliteCountry.initialize();
 		
 		//changes [from - to - desc]
+		//0.71 - 0.72 dates to YYYY-MM-DD
 		//0.70 - 0.71 created personNotUploadTable on client
 		//0.69 - 0.70 added showPower to preferences
 		//0.68 - 0.69 added Gesell-DBT test
@@ -1167,6 +1179,99 @@ Log.WriteLine("home is: " + home);
 		dbcmd.ExecuteNonQuery();
 	}
 
+	//to convert to sqlite 0.72
+	protected internal static void datesToYYYYMMDD()
+	{
+		conversionRateTotal = 4;
+		conversionRate = 1;
+		conversionSubRateTotal = -1;
+
+		/* person table */
+
+		dbcmd.CommandText = "SELECT uniqueID, dateBorn FROM person";
+		SqliteDataReader reader;
+		reader = dbcmd.ExecuteReader();
+		ArrayList myArray = new ArrayList(1);
+		while(reader.Read()) 
+			myArray.Add (reader[0].ToString() + ":" + reader[1].ToString());
+
+		reader.Close();
+
+		/*
+		   convert dates from D/M/Y
+		   to YYYY-MM-DD
+		   */
+		conversionSubRateTotal = myArray.Count;
+		conversionSubRate = 1;
+		foreach(string str in myArray) {
+			string [] id_date = str.Split(new char[] {':'});
+			DateTime dt = UtilDate.FromSql(id_date[1]);
+			dbcmd.CommandText = "UPDATE person set dateBorn = '" + UtilDate.ToSql(dt) +
+				"' WHERE uniqueID = " + id_date[0];
+			Log.WriteLine(dbcmd.CommandText.ToString());
+			dbcmd.ExecuteNonQuery();
+			conversionSubRate ++;
+		}
+
+		conversionRate ++;
+
+		/* session table */
+
+		dbcmd.CommandText = "SELECT uniqueID, date FROM session";
+		reader = dbcmd.ExecuteReader();
+		myArray = new ArrayList(1);
+		while(reader.Read()) 
+			myArray.Add (reader[0].ToString() + ":" + reader[1].ToString());
+
+		reader.Close();
+
+		/*
+		   convert dates from D/M/Y
+		   to YYYY-MM-DD
+		   */
+		conversionSubRateTotal = myArray.Count;
+		conversionSubRate = 1;
+		foreach(string str in myArray) {
+			string [] id_date = str.Split(new char[] {':'});
+			DateTime dt = UtilDate.FromSql(id_date[1]);
+			dbcmd.CommandText = "UPDATE session set date = '" + UtilDate.ToSql(dt) +
+				"' WHERE uniqueID = " + id_date[0];
+			Log.WriteLine(dbcmd.CommandText.ToString());
+			dbcmd.ExecuteNonQuery();
+			conversionSubRate ++;
+		}
+
+		conversionRate ++;
+		
+		/* SEvaluator table */
+
+		dbcmd.CommandText = "SELECT uniqueID, dateBorn FROM SEvaluator";
+		reader = dbcmd.ExecuteReader();
+		myArray = new ArrayList(1);
+		while(reader.Read()) 
+			myArray.Add (reader[0].ToString() + ":" + reader[1].ToString());
+
+		reader.Close();
+
+		/*
+		   convert dates from D/M/Y
+		   to YYYY-MM-DD
+		   */
+		conversionSubRateTotal = myArray.Count;
+		conversionSubRate = 1;
+		foreach(string str in myArray) {
+			string [] id_date = str.Split(new char[] {':'});
+			DateTime dt = UtilDate.FromSql(id_date[1]);
+			dbcmd.CommandText = "UPDATE SEvaluator set dateBorn = '" + UtilDate.ToSql(dt) +
+				"' WHERE uniqueID = " + id_date[0];
+			Log.WriteLine(dbcmd.CommandText.ToString());
+			dbcmd.ExecuteNonQuery();
+			conversionSubRate ++;
+		}
+		conversionRate ++;
+	}
+
+
 	protected internal static void convertTables(Sqlite sqliteObject, string tableName, int columnsBefore, ArrayList columnsToAdd, bool putDescriptionInMiddle) 
 	{
 		conversionSubRate = 1;
diff --git a/src/sqlite/person.cs b/src/sqlite/person.cs
index ebbed79..3255660 100644
--- a/src/sqlite/person.cs
+++ b/src/sqlite/person.cs
@@ -42,7 +42,7 @@ class SqlitePerson : Sqlite
 			"uniqueID INTEGER PRIMARY KEY, " +
 			"name TEXT, " +
 			"sex TEXT, " +
-			"dateborn TEXT, " +
+			"dateborn TEXT, " + //YYYY-MM-DD since db 0.72
 			"height INT, " +
 			"weight INT, " + //now used personSession and person can change weight in every session. person.weight is not used
 			"sportID INT, " + 
@@ -57,8 +57,7 @@ class SqlitePerson : Sqlite
 
 	//can be "Constants.PersonTable" or "Constants.ConvertTempTable"
 	//temp is used to modify table between different database versions if needed
-	//public static int Insert(bool dbconOpened, string tableName, string name, string sex, string dateBorn, int height, int weight, int sportID, bool sportUserDefined, int practice, string description)
-	public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string sex, string dateBorn, int height, int weight, int sportID, int speciallityID, int practice, string description, int race, int countryID, int serverUniqueID)
+	public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string sex, DateTime dateBorn, int height, int weight, int sportID, int speciallityID, int practice, string description, int race, int countryID, int serverUniqueID)
 	{
 		if(! dbconOpened)
 			dbcon.Open();
@@ -67,9 +66,8 @@ class SqlitePerson : Sqlite
 			uniqueID = "NULL";
 
 		string myString = "INSERT INTO " + tableName + 
-			//" (uniqueID, name, sex, dateBorn, height, weight,  sportID, speciallityID, practice, description) VALUES (NULL, '" +
 			" (uniqueID, name, sex, dateBorn, height, weight,  sportID, speciallityID, practice, description, race, countryID, serverUniqueID) VALUES (" + uniqueID + ", '" +
-			name + "', '" + sex + "', '" + dateBorn + "', " + 
+			name + "', '" + sex + "', '" + UtilDate.ToSql(dateBorn) + "', " + 
 			height + ", " + "-1" + ", " + //"-1" is weight because it's defined in personSesionWeight for allow change between sessions
 			sportID + ", " + speciallityID + ", " + practice + ", '" + description + "', " + 
 			race + ", " + countryID + ", " + serverUniqueID + ")" ;
@@ -215,7 +213,7 @@ finishForeach:
 			
 			if (!found) {
 				myArray2.Add (reader2[0].ToString() + ":" + reader2[1].ToString() + ":" +
-						reader2[2].ToString() + ":" + reader2[3].ToString() + ":" +
+						reader2[2].ToString() + ":" + UtilDate.FromSql(reader2[3].ToString()).ToShortDateString() + ":" +
 						reader2[4].ToString() + ":" + 
 						reader2[13].ToString() + ":" + //weight (from personSessionWeight)
 						reader2[14].ToString() + ":" + //sportName
@@ -264,7 +262,9 @@ finishForeach:
 		reader = dbcmd.ExecuteReader();
 		while(reader.Read()) {
 			arraySessions.Add ( reader[0].ToString() + ":" + reader[1].ToString() + ":" +
-					reader[2].ToString() + ":" + reader[3].ToString() );
+					reader[2].ToString() + ":" + 
+					UtilDate.FromSql(reader[3].ToString()).ToShortDateString()
+					);
 		}
 		reader.Close();
 
@@ -457,7 +457,7 @@ finishForeach:
 		dbcmd.CommandText = "UPDATE " + Constants.PersonTable + 
 			" SET name = '" + myPerson.Name + 
 			"', sex = '" + myPerson.Sex +
-			"', dateborn = '" + myPerson.DateBorn +
+			"', dateborn = '" + UtilDate.ToSql(myPerson.DateBorn) +
 			"', height = " + myPerson.Height +
 			", weight = " + myPerson.Weight +
 			", sportID = " + myPerson.SportID +
diff --git a/src/sqlite/personSession.cs b/src/sqlite/personSession.cs
index 2f744e0..4ef414d 100644
--- a/src/sqlite/personSession.cs
+++ b/src/sqlite/personSession.cs
@@ -149,11 +149,8 @@ class SqlitePersonSession : Sqlite
 		bool exists = new bool();
 		exists = false;
 		
-		while(reader.Read()) {
+		while(reader.Read()) 
 			exists = true;
-			//Log.WriteLine("valor {0}", reader[0].ToString());
-		}
-		//Log.WriteLine("exists = {0}", exists.ToString());
 
 		dbcon.Close();
 		return exists;
@@ -191,7 +188,7 @@ class SqlitePersonSession : Sqlite
 		}
 
 		Person myPerson = new Person(uniqueID, values[0], 
-			values[1], values[2], Convert.ToInt32(values[3]), Convert.ToInt32(values[4]), 
+			values[1], UtilDate.FromSql(values[2]), Convert.ToInt32(values[3]), Convert.ToInt32(values[4]), 
 			Convert.ToInt32(values[5]), Convert.ToInt32(values[6]), Convert.ToInt32(values[7]),
 			values[8], //desc
 			Convert.ToInt32(values[9]), Convert.ToInt32(values[10]), Convert.ToInt32(values[11])
@@ -223,7 +220,7 @@ class SqlitePersonSession : Sqlite
 					Convert.ToInt32(reader[0].ToString()),	//uniqueID
 					reader[1].ToString(),			//name
 					reader[2].ToString(),			//sex
-					reader[3].ToString(),			//dateBorn
+					UtilDate.FromSql(reader[3].ToString()),	//dateBorn
 					Convert.ToInt32(reader[4].ToString()),	//height
 					Convert.ToInt32(reader[13].ToString()),	//weight (personSessionWeight)
 					Convert.ToInt32(reader[6].ToString()),	//sportID
@@ -274,8 +271,9 @@ class SqlitePersonSession : Sqlite
 				string levelName = Catalog.GetString(Util.FindLevelName(Convert.ToInt32(reader[8])));
 
 				myArray.Add (
-						reader[0].ToString() + ":" + reader[1].ToString() + ":" + //id, name
-						reader[2].ToString() + ":" + reader[3].ToString() + ":" + //sex, dateborn
+						reader[0].ToString() + ":" + reader[1].ToString() + ":" + 	//id, name
+						reader[2].ToString() + ":" + 					//sex
+						UtilDate.FromSql(reader[3].ToString()).ToShortDateString() + ":" +	//dateborn
 						reader[4].ToString() + ":" + reader[13].ToString() + ":" + //height, weight (from personSessionWeight)
 						sportName + ":" + speciallityName + ":" + levelName + ":" +
 						reader[9].ToString()  //desc
diff --git a/src/sqlite/server.cs b/src/sqlite/server.cs
index ab9dff1..f302378 100644
--- a/src/sqlite/server.cs
+++ b/src/sqlite/server.cs
@@ -42,7 +42,7 @@ class SqliteServer : Sqlite
 			"cjVersion TEXT, " +
 			"osVersion TEXT, " +
 			"IP TEXT, " +
-			"date TEXT ) ";
+			"date TEXT ) "; //YYYY-MM-DD since db 0.72
 		dbcmd.ExecuteNonQuery();
 	 }
 
@@ -54,7 +54,7 @@ class SqliteServer : Sqlite
 			"code TEXT, " +
 			"name TEXT, " +
 			"email TEXT, " +
-			"dateborn TEXT, " +
+			"dateborn TEXT, " + //YYYY-MM-DD since db 0.72
 			"countryID INT, " + //foreign key
 			"chronometer TEXT, " +
 			"device TEXT, " +
@@ -64,7 +64,7 @@ class SqliteServer : Sqlite
 	 }
 
 	//public static int InsertPing(ServerPing ping)
-	public static int InsertPing(bool dbconOpened, int evaluatorID, string cjVersion, string osVersion, string ip, string date)
+	public static int InsertPing(bool dbconOpened, int evaluatorID, string cjVersion, string osVersion, string ip, DateTime date)
 	{
 		if(! dbconOpened)
 			dbcon.Open();
@@ -75,7 +75,7 @@ class SqliteServer : Sqlite
 			" (uniqueID, evaluatorID, cjVersion, osVersion, IP, date) VALUES (" + 
 			uniqueID + ", " + evaluatorID + ", '" + 
 			cjVersion + "', '" + osVersion + "', '" +
-			ip + "', '" + date + "')" ;
+			ip + "', '" + UtilDate.ToSql(date) + "')" ;
 		
 		dbcmd.CommandText = myString;
 		
@@ -90,7 +90,7 @@ class SqliteServer : Sqlite
 		return myReturn;
 	}
 
-	public static int InsertEvaluator(bool dbconOpened, string code, string name, string email, string dateBorn, 
+	public static int InsertEvaluator(bool dbconOpened, string code, string name, string email, DateTime dateBorn, 
 			int countryID, string chronometer, string device, string comments, bool confiable)
 	{
 		if(! dbconOpened)
@@ -102,7 +102,7 @@ class SqliteServer : Sqlite
 			" (uniqueID, code, name, email, dateBorn, countryID, chronometer, device, comments, confiable) VALUES (" + 
 			uniqueID + ", '" + 
 			code + "', '" + name + "', '" + 
-			email + "', '" + dateBorn + "', " +
+			email + "', '" + UtilDate.ToSql(dateBorn) + "', " +
 			countryID + ", '" + chronometer + "', '" + 
 			device + "', '" + comments + "', " +
 			//Util.BoolToInt(confiable) + 
@@ -122,7 +122,7 @@ class SqliteServer : Sqlite
 		return myReturn;
 	}
 	
-	public static void UpdateEvaluator(bool dbconOpened, int uniqueID, string code, string name, string email, string dateBorn, 
+	public static void UpdateEvaluator(bool dbconOpened, int uniqueID, string code, string name, string email, DateTime dateBorn, 
 			int countryID, string chronometer, string device, string comments, bool confiable)
 	{
 		if(! dbconOpened)
@@ -131,7 +131,7 @@ class SqliteServer : Sqlite
 			" SET code = '" + code +
 			"' , name = '" + name +
 			"' , email = '" + email +
-			"' , dateBorn = '" + dateBorn +
+			"' , dateBorn = '" + UtilDate.ToSql(dateBorn) +
 			"' , countryID = " + countryID +
 			", chronometer = '" + chronometer +
 			"', device = '" + device +
@@ -167,7 +167,7 @@ class SqliteServer : Sqlite
 			myEval.Code = reader[1].ToString(); 
 			myEval.Name = reader[2].ToString(); 
 			myEval.Email = reader[3].ToString(); 
-			myEval.DateBorn = reader[4].ToString();
+			myEval.DateBorn = UtilDate.FromSql(reader[4].ToString());
 			myEval.CountryID = Convert.ToInt32(reader[5].ToString());
 			myEval.Chronometer = reader[6].ToString();
 			myEval.Device = reader[7].ToString();
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index dd409ad..a2cd25d 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -43,7 +43,7 @@ class SqliteSession : Sqlite
 			"uniqueID INTEGER PRIMARY KEY, " +
 			"name TEXT, " +
 			"place TEXT, " +
-			"date TEXT, " +		
+			"date TEXT, " +	 //YYYY-MM-DD since db 0.72	
 			"personsSportID INT, " + 
 			"personsSpeciallityID INT, " + 
 			"personsPractice INT, " + //also called "level"
@@ -53,7 +53,7 @@ class SqliteSession : Sqlite
 		dbcmd.ExecuteNonQuery();
 	}
 	
-	public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string place, string date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments, int serverUniqueID)
+	public static int Insert(bool dbconOpened, string tableName, string uniqueID, string name, string place, DateTime date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments, int serverUniqueID)
 	{
 		if(! dbconOpened)
 			dbcon.Open();
@@ -63,7 +63,7 @@ class SqliteSession : Sqlite
 
 		dbcmd.CommandText = "INSERT INTO " + tableName + " (uniqueID, name, place, date, personsSportID, personsSpeciallityID, personsPractice, comments, serverUniqueID)" +
 			" VALUES (" + uniqueID + ", '"
-			+ name + "', '" + place + "', '" + date + "', " + 
+			+ name + "', '" + place + "', '" + UtilDate.ToSql(date) + "', " + 
 			personsSportID + ", " + personsSpeciallityID + ", " + 
 			personsPractice + ", '" + comments + "', " +
 			serverUniqueID + ")" ;
@@ -77,13 +77,13 @@ class SqliteSession : Sqlite
 		return myReturn;
 	}
 
-	public static void Update(int uniqueID, string name, string place, string date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments) 
+	public static void Update(int uniqueID, string name, string place, DateTime date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments) 
 	{
 		//TODO: serverUniqueID (but cannot be changed in gui/edit, then not need now)
 		dbcon.Open();
 		dbcmd.CommandText = "UPDATE " + Constants.SessionTable + " " +
 			" SET name = '" + name +
-			"' , date = '" + date +
+			"' , date = '" + UtilDate.ToSql(date) +
 			"' , place = '" + place +
 			"' , personsSportID = " + personsSportID +
 			", personsSpeciallityID = " + personsSpeciallityID +
@@ -142,7 +142,7 @@ class SqliteSession : Sqlite
 		}
 
 		Session mySession = new Session(values[0], 
-			values[1], values[2], values[3], 
+			values[1], values[2], UtilDate.FromSql(values[3]), 
 			Convert.ToInt32(values[4]), Convert.ToInt32(values[5]), Convert.ToInt32(values[6]), 
 			values[7], Convert.ToInt32(values[8]) );
 		
@@ -177,10 +177,10 @@ class SqliteSession : Sqlite
 		while(reader.Read()) {
 			if(commentsDisable) {
 				myArray.Add (reader[0].ToString() + ":" + reader[1].ToString() + ":" +
-						reader[2].ToString() + ":" + reader[3].ToString() );
+						reader[2].ToString() + ":" + UtilDate.FromSql(reader[3].ToString()).ToShortDateString() );
 			} else {
 				myArray.Add (reader[0].ToString() + ":" + reader[1].ToString() + ":" +
-						reader[2].ToString() + ":" + reader[3].ToString() + ":" +
+						reader[2].ToString() + ":" + UtilDate.FromSql(reader[3].ToString()).ToShortDateString() + ":" +
 						reader[4].ToString() );
 			}
 			count ++;
@@ -228,7 +228,7 @@ class SqliteSession : Sqlite
 			string levelName = Catalog.GetString(Util.FindLevelName(Convert.ToInt32(reader[6])));
 
 			myArray.Add (reader[0].ToString() + ":" + reader[1].ToString() + ":" +
-					reader[2].ToString() + ":" + reader[3].ToString() + ":" +
+					reader[2].ToString() + ":" + UtilDate.FromSql(reader[3].ToString()).ToShortDateString() + ":" +
 					sportName + ":" + speciallityName + ":" +
 					levelName + ":" + reader[7].ToString() ); //desc
 			count ++;
@@ -565,7 +565,8 @@ class SqliteSession : Sqlite
 		SqliteDataReader reader;
 		reader = dbcmd.ExecuteReader();
 		while(reader.Read()) {
-			Session mySession = new Session(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), 
+			Session mySession = new Session(reader[0].ToString(), reader[1].ToString(), 
+					reader[2].ToString(), UtilDate.FromSql(reader[3].ToString()), 
 					1, //sport undefined
 					-1, //speciallity undefined
 					-1, //practice level undefined
@@ -578,7 +579,7 @@ class SqliteSession : Sqlite
 
 		foreach (Session mySession in myArray)
 			InsertOld(true, Constants.ConvertTempTable,
-				mySession.Name, mySession.Place, mySession.Date, 
+				mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date), 
 				mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);
 
 		//3rd drop table sessions
@@ -591,7 +592,7 @@ class SqliteSession : Sqlite
 		//5th insert data in sessions (with sport related stuff)
 		foreach (Session mySession in myArray) 
 			InsertOld(true, Constants.SessionTable,
-				mySession.Name, mySession.Place, mySession.Date, 
+				mySession.Name, mySession.Place, UtilDate.ToSql(mySession.Date), 
 				mySession.PersonsSportID, mySession.PersonsSpeciallityID, mySession.PersonsPractice, mySession.Comments);
 
 
@@ -631,7 +632,7 @@ class SqliteServerSession : SqliteSession
 			", evaluatorID INT " +
 			", evaluatorCJVersion TEXT " + 
 			", evaluatorOS TEXT " +
-			", uploadedDate TEXT " +
+			", uploadedDate TEXT " + //YYYY-MM-DD since db 0.72	
 			", uploadingState INT ";
 
 		dbcmd.CommandText = 
@@ -639,7 +640,7 @@ class SqliteServerSession : SqliteSession
 			"uniqueID INTEGER PRIMARY KEY, " +
 			"name TEXT, " +
 			"place TEXT, " +
-			"date TEXT, " +		
+			"date TEXT, " +	//YYYY-MM-DD since db 0.72		
 			"personsSportID INT, " + 
 			"personsSpeciallityID INT, " + 
 			"personsPractice INT, " + //also called "level"
@@ -650,7 +651,7 @@ class SqliteServerSession : SqliteSession
 		dbcmd.ExecuteNonQuery();
 	}
 	
-	public static int Insert(bool dbconOpened, string tableName, string name, string place, string date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments, int serverUniqueID, int evaluatorID, string evaluatorCJVersion, string evaluatorOS, string uploadedDate, int uploadingState)
+	public static int Insert(bool dbconOpened, string tableName, string name, string place, DateTime date, int personsSportID, int personsSpeciallityID, int personsPractice, string comments, int serverUniqueID, int evaluatorID, string evaluatorCJVersion, string evaluatorOS, DateTime uploadedDate, int uploadingState)
 	{
 		if(! dbconOpened)
 			dbcon.Open();
@@ -661,12 +662,12 @@ class SqliteServerSession : SqliteSession
 
 		dbcmd.CommandText = "INSERT INTO " + tableName + " (uniqueID, name, place, date, personsSportID, personsSpeciallityID, personsPractice, comments, serverUniqueID, evaluatorID, evaluatorCJVersion, evaluatorOS, uploadedDate, uploadingState)" +
 			" VALUES (" + uniqueID + ", '"
-			+ name + "', '" + place + "', '" + date + "', " + 
+			+ name + "', '" + place + "', '" + UtilDate.ToSql(date) + "', " + 
 			personsSportID + ", " + personsSpeciallityID + ", " + 
 			personsPractice + ", '" + comments + "', " +
 			serverUniqueID + ", " + evaluatorID + ", '" +
 			evaluatorCJVersion + "', '" + evaluatorOS + "', '" +
-			uploadedDate + "', " + uploadingState +
+			UtilDate.ToSql(uploadedDate) + "', " + uploadingState +
 			")" ;
 		Log.WriteLine(dbcmd.CommandText.ToString());
 		dbcmd.ExecuteNonQuery();
diff --git a/src/stats/main.cs b/src/stats/main.cs
index 2dcdb81..ba485a0 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -356,7 +356,7 @@ public class Stat
 				//we need to know the name of the column: session
 				stringFullResults = sessions[i].ToString().Split(new char[] {':'});
 				myHeaderString = stringFullResults[1] + "\n" + 
-					Util.DateAsDateTime(stringFullResults[2]).ToShortDateString() + "\n" + 
+					stringFullResults[2] + "\n" + 
 					Catalog.GetString(columnsString[1]); //name, date, col name
 				treeview.AppendColumn (myHeaderString, new CellRendererText(), "text", i+2); 
 			}
@@ -384,7 +384,7 @@ public class Stat
 				stringFullResults = sessions[i].ToString().Split(new char[] {':'});
 				
 				myHeaderString += "<TH>" + stringFullResults[1] + "\n" + 
-					Util.DateAsDateTime(stringFullResults[2]).ToShortDateString() + "\n" + 
+					stringFullResults[2] + "\n" + 
 					Catalog.GetString(columnsString[1]) + "</TH>"; //name, date, col name
 			}
 			//if multisession, add AVG and SD cols
diff --git a/src/util.cs b/src/util.cs
index f35e6d0..90a957a 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -97,6 +97,16 @@ public class Util
 		else 
 			return Math.Round(Convert.ToDouble(time), prefsDigitsNumber).ToString();
 	}
+
+	//if passed (number=1, digits=4)
+	//takes 1 and returns "0001" 
+	public static string DigitsCreate (int number, int digits)
+	{
+		string str = number.ToString();
+		while(str.Length < digits)
+			str = "0" + str;
+		return str;
+	}
 	
 	public static double GetMax (string values)
 	{
@@ -619,34 +629,6 @@ public class Util
 		return osString;
 	}
 	
-	public static DateTime DateAsDateTime (string dateString) {
-		string [] dateFull = dateString.Split(new char[] {'/'});
-		DateTime dateTime;
-
-		//fixes bug with really old chronojump versions where default date was 0/0/1900
-		if(dateFull[0] == "0")
-			dateFull[0] = "1";
-		if(dateFull[1] == "0")
-			dateFull[1] = "1";
-
-		try {
-			//Datetime (year, month, day) constructor
-			dateTime = new DateTime(
-					Convert.ToInt32(dateFull[2]), 
-					Convert.ToInt32(dateFull[1]), 
-					Convert.ToInt32(dateFull[0]));
-		}
-		catch {
-			//Datetime (year, month, day) constructor
-			//in old chronojump versions, date was recorded in a different way, solve like this
-			dateTime = new DateTime(
-					Convert.ToInt32(dateFull[2]), 
-					Convert.ToInt32(dateFull[0]), 
-					Convert.ToInt32(dateFull[1]));
-		}
-		return dateTime;
-	}
-
 	public static string GetReallyOldDatabaseDir() {
 		return Environment.GetEnvironmentVariable("HOME")+ Path.DirectorySeparatorChar + ".chronojump";
 	}
@@ -715,22 +697,11 @@ public class Util
 		}
 	}
 
-	public static string DateParse(string myDate) {
-		StringBuilder myStringBuilder = new StringBuilder(myDate);
-		//for not having problems with the directories:
-		myStringBuilder.Replace(" ", "_"); //replace the ' ' (date-hour separator) for '_' 
-		myStringBuilder.Replace("/", "-"); //replace the '/' (date separator) for '-' 
-		myStringBuilder.Replace(":", "-"); //replace the ':' (hour separator) for '-'
-		myStringBuilder.Replace(".", ""); //delete the '.' in a.m.: 13-01-2009_02-05-43_a.m.
-
-		return myStringBuilder.ToString();
-	}
-
 	public static void BackupDatabase () {
 		string homeDir = GetDatabaseDir();
 		string backupDir = homeDir + "/backup";
 		
-		string dateParsed = DateParse(DateTime.Now.ToString());
+		string dateParsed = UtilDate.ToFile(DateTime.Now);
 
 		if(File.Exists(System.IO.Path.Combine(homeDir, "chronojump.db")))
 			File.Copy(System.IO.Path.Combine(homeDir, "chronojump.db"), 
diff --git a/src/utilDate.cs b/src/utilDate.cs
new file mode 100644
index 0000000..37699e0
--- /dev/null
+++ b/src/utilDate.cs
@@ -0,0 +1,91 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Xavier de Blas: 
+ */
+
+using System;
+using System.Text; //StringBuilder
+using System.Collections; //ArrayList
+
+//this class tries to be a space for methods that are used in different classes
+public class UtilDate
+{
+	//comes datetime
+	//insert in sql like YYYY-MM-DD (with always all digits)
+	//we use Year, Month and Day for not having any problem with locale
+	public static string ToSql (DateTime dt)
+	{
+		return Util.DigitsCreate(dt.Year,4) + "-" + 
+			Util.DigitsCreate(dt.Month,2) + "-" + 
+			Util.DigitsCreate(dt.Day,2);
+	}
+	
+	//records date & time, useful to backup database without having strange chars on filename
+	public static string ToFile (DateTime dt)
+	{
+		return Util.DigitsCreate(dt.Year,4) + "-" + 
+			Util.DigitsCreate(dt.Month,2) + "-" + 
+			Util.DigitsCreate(dt.Day,2) + "_" +
+			Util.DigitsCreate(dt.Hour,2) + "-" + 
+			Util.DigitsCreate(dt.Minute,2) + "-" + 
+			Util.DigitsCreate(dt.Second,2);
+	}
+
+
+	//comes from sql like YYYY-MM-DD (with always all digits)
+	//return datetime
+	public static DateTime FromSql (string date)
+	{
+		try {
+			/*
+			   maybe date format is before 0.72 (d/m/Y)
+			   this is still here and not in a standalone conversion
+			   because if someone converts from older database
+			   can have problems wih constructors with different date formats
+			 */
+
+			DateTime dt; //Datetime (year, month, day) constructor
+			if(date.IndexOf('/') == -1) { 
+				//not contains '/'
+				//new sqlite3 compatible date format sice db 0.72 YYYY-MM-DD
+				string [] dateFull = date.Split(new char[] {'-'});
+				dt = new DateTime(
+						Convert.ToInt32(dateFull[0]), 
+						Convert.ToInt32(dateFull[1]), 
+						Convert.ToInt32(dateFull[2]));
+			} else {
+				//contains '/'
+				//old D/M/Y format 
+				string [] dateFull = date.Split(new char[] {'/'});
+				dt = new DateTime(
+						Convert.ToInt32(dateFull[2]), 
+						Convert.ToInt32(dateFull[1]), 
+						Convert.ToInt32(dateFull[0]));
+			}
+			return dt;
+		}
+		catch {
+			/*
+			   on report we do a session select with uniqueID = -1
+			   it returns nothing, date has nothing
+			   */
+			return DateTime.Now;
+		}
+	}
+
+}



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