Small refactoring in DateTime comparing methods
authorTarek Mahmoud Sayed <tarekms@microsoft.com>
Thu, 18 Feb 2016 22:19:09 +0000 (14:19 -0800)
committerTarek Mahmoud Sayed <tarekms@microsoft.com>
Thu, 18 Feb 2016 22:19:09 +0000 (14:19 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/0148107cff7f462a601d91a8a119208b11a832a4

src/coreclr/src/mscorlib/src/System/DateTime.cs

index 9105db8..6a496ac 100644 (file)
@@ -487,20 +487,12 @@ namespace System {
             if (!(value is DateTime)) {
                 throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDateTime"));
             }
-    
-            long valueTicks = ((DateTime)value).InternalTicks;
-            long ticks = InternalTicks;
-            if (ticks > valueTicks) return 1;
-            if (ticks < valueTicks) return -1;
-            return 0;
+            
+            return Compare(this, (DateTime)value);
         }
 
         public int CompareTo(DateTime value) {
-            long valueTicks = value.InternalTicks;
-            long ticks = InternalTicks;
-            if (ticks > valueTicks) return 1;
-            if (ticks < valueTicks) return -1;
-            return 0;
+            return Compare(this, value);
         }
     
         // Returns the tick count corresponding to the given year, month, and day.