Hello,

This patch should cleanup and optimize a bit the SqlDateTime constructors. There were some MONOTODO in there, about arounding the values, but I've checked the MSDN docs and the code logic and didn't find a reason we should round those values. Maybe someone could double check?

--
Alexandre Gomes, Portugal
Index: class/System.Data/System.Data.SqlTypes/SqlDateTime.cs
===================================================================
--- class/System.Data/System.Data.SqlTypes/SqlDateTime.cs	(revision 60092)
+++ class/System.Data/System.Data.SqlTypes/SqlDateTime.cs	(working copy)
@@ -42,8 +42,8 @@
 		private DateTime value;
 		private bool notNull;
 
-		public static readonly SqlDateTime MaxValue = new SqlDateTime (9999,12,31,23,59,59, (double)997);
-		public static readonly SqlDateTime MinValue = new SqlDateTime (1753,1,1);
+		public static readonly SqlDateTime MaxValue = new SqlDateTime (9999, 12, 31, 23, 59, 59, (double)997);
+		public static readonly SqlDateTime MinValue = new SqlDateTime (1753, 1, 1);
 		public static readonly SqlDateTime Null;
 		public static readonly int SQLTicksPerHour = 1080000;
 		public static readonly int SQLTicksPerMinute = 18000;
@@ -72,29 +72,12 @@
 			CheckRange (this);
 		}
 
-		public SqlDateTime (int year, int month, int day) 
-		{
-			try {
-				this.value = new DateTime (year, month, day);
-			} catch (ArgumentOutOfRangeException ex) {
-				throw new SqlTypeException (ex.Message);
-			}
-			notNull = true;
-			CheckRange (this);
-		}
+		public SqlDateTime (int year, int month, int day) : this (year, month, day, 0, 0, 0, (double) 0)
+		{ }
 
-		public SqlDateTime (int year, int month, int day, int hour, int minute, int second) 
-		{
-			try {
-				this.value = new DateTime (year, month, day, hour, minute, second);
-			} catch (ArgumentOutOfRangeException ex) {
-				throw new SqlTypeException (ex.Message);
-			}
-			notNull = true;
-			CheckRange (this);
-		}
+		public SqlDateTime (int year, int month, int day, int hour, int minute, int second) : this (year, month, day, hour, minute, second, (double) 0)
+		{ }
 
-		[MonoTODO ("Round milisecond")]
 		public SqlDateTime (int year, int month, int day, int hour, int minute, int second, double millisecond) 
 		{
 			try {
@@ -109,20 +92,8 @@
 			CheckRange (this);
 		}
 
-		[MonoTODO ("Round bilisecond")]
-		public SqlDateTime (int year, int month, int day, int hour, int minute, int second, int bilisecond) // bilisecond??
-		{
-			try {
-				DateTime t = new DateTime(year, month, day, hour, minute, second);
-			
-				long dateTick = (long) (t.Ticks + bilisecond * 10);
-				this.value = new DateTime (dateTick);
-			} catch (ArgumentOutOfRangeException ex) {
-				throw new SqlTypeException (ex.Message);
-			}
-			notNull = true;
-			CheckRange (this);
-		}
+		public SqlDateTime (int year, int month, int day, int hour, int minute, int second, int bilisecond) : this (year, month, day, hour, minute, second, (double) bilisecond / 1000)
+		{ }
 
 		#endregion
 
Index: class/System.Data/System.Data.SqlTypes/ChangeLog
===================================================================
--- class/System.Data/System.Data.SqlTypes/ChangeLog	(revision 60092)
+++ class/System.Data/System.Data.SqlTypes/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2006-04-30  Alexandre Miguel Pedro Gomes  <[EMAIL PROTECTED]>
+
+	* SqlDateTime.cs: Constructor cleaup, optimizations and MONOTODO
+	attribute removal.
+
 2006-02-17  Chris Toshok  <[EMAIL PROTECTED]>
 
 	* StorageState.cs: correct namespace, and remove "Delayed"
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to