-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(battle): calculate current week in UTC
- Loading branch information
Showing
5 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import getUTCISOWeekSrc from 'date-fns/esm/_lib/getUTCISOWeek/index.js'; | ||
|
||
const getUTCISOWeek = getUTCISOWeekSrc.default || getUTCISOWeekSrc; | ||
console.log(getUTCISOWeek); | ||
/** | ||
* | ||
* @param {Date|number} dateLeft | ||
* @param {Date|number} dateRight | ||
* @return {number} | ||
*/ | ||
export function differenceInCalendarUTCISOWeeks(dateLeft, dateRight) { | ||
return getUTCISOWeek(dateLeft) - getUTCISOWeek(dateRight); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Custom Jest transform implementation that wraps babel-jest and injects our | ||
// babel presets, so we don't have to use .babelrc. | ||
|
||
import babelJest from 'babel-jest'; | ||
const createTransformer = babelJest.createTransformer || babelJest.default.createTransformer; | ||
export default createTransformer({ | ||
babelrc: false, | ||
"presets": ["@babel/preset-env"], | ||
// ignore: false, // do nothing, jest's transformIgnorePatterns works instead | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {differenceInCalendarUTCISOWeeks} from '~/assets/utils/date-fns.js'; | ||
|
||
test('differenceInCalendarUTCISOWeeks', () => { | ||
const BATTLE_START_DATE = new Date('2022-10-24T00:00:00Z'); | ||
const now = new Date("2022-11-07T01:20:44.498+03:00"); | ||
expect(differenceInCalendarUTCISOWeeks(new Date("2022-11-07T01:20:44.498+03:00"), BATTLE_START_DATE)) | ||
.toBe(1); | ||
expect(differenceInCalendarUTCISOWeeks(new Date("2022-11-07T01:20:44.498Z"), BATTLE_START_DATE)) | ||
.toBe(2); | ||
}); |