Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare and equal #84

Merged
merged 12 commits into from
Jun 11, 2023
Prev Previous commit
Next Next commit
Add Date.equal, Date.compare
  • Loading branch information
cknitt committed Jun 11, 2023
commit f35ba39b8fa5c3d180cab604f419c17f3e7a45b1
11 changes: 11 additions & 0 deletions src/Core__Date.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Core__Float from "./Core__Float.mjs";

var UTC = {};

function equal(a, b) {
return a.getTime() === b.getTime();
}

function compare(a, b) {
return Core__Float.compare(a.getTime(), b.getTime());
}

export {
UTC ,
equal ,
compare ,
}
/* No side effect */
4 changes: 4 additions & 0 deletions src/Core__Date.res
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ module UTC = {
@send external getTime: t => msSinceEpoch = "getTime"
@send external getTimezoneOffset: t => int = "getTimezoneOffset"

let equal = (a, b) => a->getTime === b->getTime

let compare = (a, b) => Core__Float.compare(a->getTime, b->getTime)

// Locale
@send external getFullYear: t => int = "getFullYear"
@send external getMonth: t => int = "getMonth"
Expand Down
4 changes: 4 additions & 0 deletions src/Core__Date.resi
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ Returns the time, in milliseconds, between UNIX epoch (January 1, 1970 00:00:00
@val
external now: unit => msSinceEpoch = "Date.now"

let equal: (t, t) => bool

let compare: (t, t) => int

/**
`getTime(date)`

Expand Down