Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jscomp/runtime/caml_obj.ml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ let rec caml_compare (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : int =
if len_a = len_b then
if O.isArray(a)
then aux_same_length a b 0 len_a
else if [%raw{|a instanceof Date && b instanceof Date|}] then
[%raw{|a - b|}]
else aux_obj_compare a b
else if len_a < len_b then
aux_length_a_short a b 0 len_a
Expand Down Expand Up @@ -327,6 +329,8 @@ let rec caml_equal (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : bool =
if len_a = len_b then
if O.isArray(a)
then aux_equal_length a b 0 len_a
else if [%raw{|a instanceof Date && b instanceof Date|}] then
not (Js.unsafe_gt a b || Js.unsafe_lt a b)
else aux_obj_equal a b
else false
and aux_equal_length (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i same_length =
Expand Down
17 changes: 16 additions & 1 deletion jscomp/test/js_date_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var Mt = require("./mt.js");
var Block = require("../../lib/js/block.js");
var Caml_obj = require("../../lib/js/caml_obj.js");

function date(param) {
return new Date("1976-03-08T12:34:56.789+01:23");
Expand Down Expand Up @@ -941,7 +942,18 @@ var suites_001 = /* :: */[
]);
})
],
/* [] */0
/* :: */[
/* tuple */[
"eq",
(function (param) {
var a = new Date("2013-03-01T01:10:00");
var b = new Date("2013-03-01T01:10:00");
var c = new Date("2013-03-01T01:10:01");
return /* Ok */Block.__(4, [Caml_obj.caml_equal(a, b) && Caml_obj.caml_notequal(b, c) && Caml_obj.caml_greaterthan(c, b)]);
})
],
/* [] */0
]
]
]
]
Expand Down Expand Up @@ -1015,6 +1027,9 @@ var suites = /* :: */[

Mt.from_pair_suites("Js_date_test", suites);

var N = 0;

exports.N = N;
exports.date = date;
exports.suites = suites;
/* Not a pure module */
Loading