Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JS Date libraries 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
luxon
52189.9 Ops/sec
date-fns
0.0 Ops/sec
dayjs
98786.0 Ops/sec
js-joda
367047.1 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/luxon@1.26.0/build/global/luxon.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@js-joda/core@3.2.0/dist/js-joda.min.js"></script> <script src="https://wzrd.in/standalone/date-fns@latest"></script> <script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script> <script src="https://unpkg.com/dayjs@1.8.21/plugin/isBetween.js"></script> <script src="https://wzrd.in/standalone/dateformat@latest"></script>
Script Preparation code:
dayjs.extend(window.dayjs_plugin_isBetween) window.__date__ = new Date('2000-01-06T03:24:11'); window.__another_date__ = new Date('2000-01-30T03:24:11'); window.__another_month__ = new Date('2000-02-01T00:00:00'); window.__another_year__ = new Date('1999-01-06T03:24:11'); window.__saturday__ = new Date('2021-05-01T03:24:11'); window.__sunday__ = new Date('2021-05-02T03:24:11'); window._expected_string = '2000/01/06'; window._expected_start = '2000/01/01'; window._expected_end = '2000/01/31'; window._expected_day_of_week = 1;
Tests:
luxon
var actual = luxon.DateTime.fromJSDate(__date__); console.assert(actual.toFormat('yyyy/MM/dd') === _expected_string); var start = actual.startOf('month'); console.assert(start.toFormat('yyyy/MM/dd') === _expected_start); var end = actual.endOf('month'); console.assert(end.toFormat('yyyy/MM/dd') === _expected_end); var i = luxon.Interval.fromDateTimes(start, end); var isBefore = luxon.DateTime.fromJSDate(__another_date__) < end; console.assert(isBefore === true); var isBetween = i.contains(actual); console.assert(isBetween === true); var isInclusive = i.contains(start); console.assert(isInclusive === true); console.assert(luxon.DateTime.fromJSDate(__saturday__).weekday === 6); console.assert(start.hasSame(end, 'month') === true); console.assert(luxon.DateTime.fromJSDate(__another_month__).hasSame(end, 'month') === false); console.assert(luxon.DateTime.fromJSDate(__another_year__).hasSame(actual, 'month') === false); console.assert(luxon.DateTime.fromJSDate(__sunday__).daysInMonth === 31);
date-fns
var actual = __date__; console.assert(dateFns.format(actual, 'YYYY/MM/DD') === _expected_string); var start = dateFns.startOfMonth(actual); console.assert(dateFns.format(start, 'YYYY/MM/DD') === _expected_start); var end = dateFns.endOfMonth(actual); console.assert(dateFns.format(end, 'YYYY/MM/DD') === _expected_end); var isBetween = dateFns.isWithinRange(actual, start, end); console.assert(isBetween === true); var isInclusive = dateFns.isWithinRange(start, start, end); console.assert(isInclusive === true); console.assert(dateFns.isSaturday(__saturday__) === true); console.assert(dateFns.isSameMonth(start, end) === true); console.assert(dateFns.isSameMonth(__another_month__, end) === false); console.assert(dateFns.isSameMonth(__another_year__, actual) === false); console.assert(dateFns.getDaysInMonth(__sunday__) === 31);
dayjs
var actual = dayjs(__date__); console.assert(actual.format('YYYY/MM/DD') === _expected_string); var start = actual.startOf('month'); console.assert(start.format('YYYY/MM/DD') === _expected_start); var end = actual.endOf('month'); console.assert(end.format('YYYY/MM/DD') === _expected_end); var isBetween = actual.isBetween(start, end); console.assert(isBetween === true); var isInclusive = start.isBetween(start, end, 'day', '[]'); console.assert(isInclusive === true); console.assert(dayjs(__saturday__).day() === 6); console.assert(start.isSame(end, 'month') === true); console.assert(dayjs(__another_month__).isSame(end, 'month') === false); console.assert(dayjs(__another_year__).isSame(actual, 'month') === false); console.assert(dayjs(__sunday__).daysInMonth() === 31);
js-joda
var actual = JSJoda.LocalDate.from(JSJoda.nativeJs(__date__)); console.assert(actual.format(JSJoda.DateTimeFormatter.ofPattern('yyyy/MM/dd')) === _expected_string); var start = actual.with(JSJoda.TemporalAdjusters.firstDayOfMonth()); console.assert(start.format(JSJoda.DateTimeFormatter.ofPattern('yyyy/MM/dd')) === _expected_start); var end = actual.with(JSJoda.TemporalAdjusters.lastDayOfMonth()); console.assert(end.format(JSJoda.DateTimeFormatter.ofPattern('yyyy/MM/dd')) === _expected_end); var isBetween = actual.compareTo(start) >= 0 && actual.compareTo(end) <= 0; console.assert(isBetween === true); var isInclusive = start.compareTo(start) >= 0 && start.compareTo(end) <= 0; console.assert(isInclusive === true); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__saturday__)).dayOfWeek() === JSJoda.DayOfWeek.SATURDAY); console.assert(start.withDayOfMonth(1).equals(end.withDayOfMonth(1))); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__another_month__)).withDayOfMonth(1).equals(end.withDayOfMonth(1)) === false); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__another_year__)).withDayOfMonth(1).equals(actual.withDayOfMonth(1)) === false); console.assert(JSJoda.LocalDate.from(JSJoda.nativeJs(__sunday__)).lengthOfMonth() === 31);