Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
meduzen committed Apr 12, 2024
1 parent cb768ad commit 4f1f861
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Compare with [last published version](https://github.com/meduzen/datetime-attrib

### Fixed

- Fix incorrect year for `datetime(date, 'week')` when the week started the previous year. For example, `2021-01-01` is a Friday and its week belongs to 2020 (as [per spec](./README.md#weeknumber). In that case, the output was `2021-53` instead of `2020-53`.
- Fix incorrect year for `datetime(date, 'week')` when the week started the previous year. For example, `2021-01-01` is a Friday and its week belongs to 2020 (as [per spec](./README.md#weeknumber)). In that case, the output was `2021-53` instead of `2020-53`.

### Improved

Expand Down
2 changes: 1 addition & 1 deletion src/datetime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('datetime', () => {
expect(datetime(january19th, 'week')).toBe('2021-W03')
})

// 1st day of the month is after Thurdsay
// 1st day of the month is after Thurdsay, but it’s not in January
test('week on 2021-03-01 is 2021-W17', () => {
const march1st2021 = new Date(2021, 4, 1)
expect(getNormalizeDay(march1st2021)).toBeGreaterThan(4)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function daysBetween(date, furtherDate) {
* @returns {number}
*/
export function weekNumber(date) {
const dayIndex = getNormalizeDay(date) // normalize index because Sunday == 0
const dayIndex = getNormalizeDay(date)

const sameWeekThursday = new Date(date)
sameWeekThursday.setDate(date.getDate() + 4 - dayIndex)
Expand All @@ -47,7 +47,7 @@ export function weekNumber(date) {
}

/**
* Get the day index of the week, except Sunday is 7 instead of 0.
* Get the day index of the week, but Sunday is now 7 instead of 0.
*
* @param {Date} date
* @returns {number}
Expand Down

0 comments on commit 4f1f861

Please sign in to comment.