[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-devel-list
Subject:    Re: [Mono-dev] Small patch to SqlDateTime
From:       "Alexandre Miguel Pedro Gomes" <alexmipego () gmail ! com>
Date:       2007-04-25 15:59:18
Message-ID: 170f4a080704250859sbb9c5c9o4d32b4cab7bfcfe4 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I've updated the patch and I hope someone can check it and give the OK to
commit.

Changelog:
 The ctors were almost duplicated, I did a cleanup redirecting to one using
the overrides making the code simpler.
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.

On 4/30/06, Alexandre Miguel Pedro Gomes <alexmipego@gmail.com> wrote:
>
> 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
>



-- 
Alexandre Gomes, Portugal

[Attachment #5 (text/html)]

I&#39;ve updated the patch and I hope someone can check it and give the OK to \
commit.<br><br>Changelog:<br>&nbsp;The ctors were almost duplicated, I did a cleanup \
redirecting to one using the overrides making the code simpler.<br> There were some \
MONOTODO in there, about arounding the values, but I&#39;ve checked the MSDN docs and \
the code logic and didn&#39;t find a reason we should round those \
values.<br><br><div><span class="gmail_quote">On 4/30/06, <b \
class="gmail_sendername">Alexandre Miguel Pedro Gomes</b> &lt;<a \
href="mailto:alexmipego@gmail.com">alexmipego@gmail.com</a>&gt; wrote:</span> \
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br><br>This patch should \
cleanup and optimize a bit the SqlDateTime constructors. There were some MONOTODO in \
there, about arounding the values, but I&#39;ve checked the MSDN docs and the code \
logic and didn&#39;t find a reason we should round those values. Maybe someone could \
double check? <br clear="all"><span class="sg"><br>-- <br>Alexandre Gomes, Portugal
</span><br clear="all"></blockquote></div><br><br clear="all"><br>-- <br>Alexandre \
Gomes, Portugal


["SqlDateTime.patch" (text/x-patch)]

Index: System.Data.SqlTypes/SqlDateTime.cs
===================================================================
--- System.Data.SqlTypes/SqlDateTime.cs	(revision 76059)
+++ System.Data.SqlTypes/SqlDateTime.cs	(working copy)
@@ -65,9 +65,10 @@
 
 		static SqlDateTime ()
 		{
-			DateTime t = new DateTime (9999, 12, 31, 23, 59, 59);
-			long ticks = (long) (t.Ticks + (997 * 10000));
-			MaxValue.value = new DateTime (ticks);
+			//DateTime t = new DateTime (9999, 12, 31, 23, 59, 59);
+			//long ticks = (long) (t.Ticks + (997 * 10000));
+			// the value of ticks would be always equal to '3155378975999970000'
+			MaxValue.value = new DateTime (3155378975999970000);
 			MaxValue.notNull = true;
 
 			MinValue.value = new DateTime (1753, 1, 1);
@@ -93,29 +94,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 {
@@ -130,20 +114,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: System.Data.SqlTypes/ChangeLog
===================================================================
--- System.Data.SqlTypes/ChangeLog	(revision 76059)
+++ System.Data.SqlTypes/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2007-04-25  Alexandre Miguel Pedro Gomes  <alexmipego@gmail.com>
+
+	* SqlDateTime.cs: The ctors were almost duplicated, I did a cleanup
+	redirecting to one using the overrides making the code simpler.
+
 2007-03-09  Nagappan A  <anagappan@novell.com>
 
 	* SqlBoolean.cs (GreaterThan, GreaterThanOrEqual, LessThan)



_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic