Start a new topic
Solved

DateTime.CompareTo is incorrect

Executing the following line in .NET runtime:

new DateTime(2015, 10, 10).CompareTo(new DateTime(2015, 11, 11))

results in -1


Executing the following line in Javascript:

new System.DateTime.ctor$2(2015,10,10).CompareTo(new System.DateTime.ctor$2(2015,11,11)) 

 results in 1526567296


This is incorrect and should be negative

Looking to the implementation, there is probably a pipeline missing :)

$p.CompareTo = function DateTime_CompareTo(other) {
return ((this.value.getTime() - other.value.getTime()) | 0);
};

 



Thanks for the reporting this issue, we will fix it in the coming v1.2 release.

This bug was fixed and tested already, as a workaround you can edit mscorlib.js:

 

$p.CompareTo = function DateTime_CompareTo(other) {
        return $d.sign(this.value.getTime() - other.value.getTime());
    };

 

Login or Signup to post a comment