From fc86a2c91cd0b846689df0a0030a7773d56c4a89 Mon Sep 17 00:00:00 2001 From: Mehdi M Date: Fri, 12 Apr 2024 23:17:35 +0200 Subject: [PATCH] Add helper to get the normalized day index on `DateTime` --- src/datetime-class.js | 8 ++++++++ src/datetime-class.test.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/datetime-class.js b/src/datetime-class.js index f9bee65..7394f42 100644 --- a/src/datetime-class.js +++ b/src/datetime-class.js @@ -1,8 +1,16 @@ import { MILLISECONDS_PER_WEEK } from './utils/const.js' import { datetime, weekNumber } from './index.js' +import { getNormalizeDay } from './utils/date.js' export class DateTime extends Date { + /** + * Get the day index of the week, except Sunday is 7 instead of 0. + * + * @returns {number} + */ + getNormalisedDay = () => getNormalizeDay(this) + /** * Returns the week of the year (`1`–`53`) of the specified date according to * local time, as defined by the WHATWG and the ISO-8601 specs: diff --git a/src/datetime-class.test.js b/src/datetime-class.test.js index c5c8748..2307aa8 100644 --- a/src/datetime-class.test.js +++ b/src/datetime-class.test.js @@ -45,6 +45,8 @@ describe('DateTime class', () => { }) }) + describe.todo('.getNormalisedDay()', () => {}) + describe('.getWeek()', () => { test('returns the week number', () => {