rendered paste bodyIndex: 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: Constructor cleaup, optimizations and obsolete
+ MONOTODO attribute removal.
+
2007-03-09 Nagappan A <anagappan@novell.com>
* SqlBoolean.cs (GreaterThan, GreaterThanOrEqual, LessThan)