Skip to content

Commit

Permalink
Rename internal getNormalizeDay into getNormalizedDay
Browse files Browse the repository at this point in the history
  • Loading branch information
meduzen committed Apr 20, 2024
1 parent 8c9fa80 commit 9540657
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/datetime.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from 'vitest'

import { datetime, datetimeTz, tzOffset, utc } from './index.js'
import { getNormalizeDay } from './utils/date.js'
import { getNormalizedDay } from './utils/date.js'

const togoIndependanceDay = new Date(1960, 3, 27)
const date = togoIndependanceDay // alias for the sake of brevity
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('datetime', () => {

// 1st day of the year is after Thurdsay
test('week on 2021-01-01 is 2020-W53', () => {
expect(getNormalizeDay(january1st2021)).toBeGreaterThan(4)
expect(getNormalizedDay(january1st2021)).toBeGreaterThan(4)
expect(datetime(january1st2021, 'week')).toBe('2020-W53')
})

Expand All @@ -109,7 +109,7 @@ describe('datetime', () => {
// 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)
expect(getNormalizedDay(march1st2021)).toBeGreaterThan(4)
expect(datetime(march1st2021, 'week')).toBe('2021-W17')
})

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)
const dayIndex = getNormalizedDay(date)

const sameWeekThursday = new Date(date)
sameWeekThursday.setDate(date.getDate() + 4 - dayIndex)
Expand All @@ -52,4 +52,4 @@ export function weekNumber(date) {
* @param {Date} date
* @returns {number}
*/
export const getNormalizeDay = date => date.getDay() || 7
export const getNormalizedDay = date => date.getDay() || 7
1 change: 1 addition & 0 deletions types/utils/date.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export function daysBetween(date: Date, furtherDate: Date): number;
* @returns {number}
*/
export function weekNumber(date: Date): number;
export function getNormalizedDay(date: Date): number;

0 comments on commit 9540657

Please sign in to comment.