import { default } from "https://deno.land/x/date_fns@v2.0.0-alpha.32/closestTo/index.js";
Examples
// Which date is closer to 6 September 2015: 1 January 2000 or 1 January 2030?
var dateToCompare = new Date(2015, 8, 6)
var result = closestTo(dateToCompare, [
new Date(2000, 0, 1),
new Date(2030, 0, 1)
])
//=> Tue Jan 01 2030 00:00:00
// Which date is closer to 6 September 2015: 1 January 2000 or 1 January 2030? var dateToCompare = new Date(2015, 8, 6) var result = closestTo(dateToCompare, [ new Date(2000, 0, 1), new Date(2030, 0, 1) ]) //=> Tue Jan 01 2030 00:00:00