Skip to content

Commit

Permalink
[✅ test] Minified React Error 원인 확인을 위한 유틸함수 수정 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
sryung1225 committed Apr 13, 2024
1 parent 6751a36 commit d539cda
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/home/RecruitingChallengeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from 'next/link';
import IRecruitingChallenge from '@/types/recruitingChallenge';
import VERIFICATION_TYPE from '@/constants/verificationType';
import screenSize from '@/constants/screenSize';
import calculateDDay from '@/utils/calculateDDay';
import calculateDDayPrev from '@/utils/calculateDDayPrev';
import calculatePeriod from '@/utils/calculatePeriod';

export default function RecruitingChallengeCard({
Expand All @@ -18,7 +18,7 @@ export default function RecruitingChallengeCard({
isFree,
}: IRecruitingChallenge) {
const caculateRecruitDDay = (date: string) => {
const dDay = calculateDDay(date) - 1;
const dDay = calculateDDayPrev(date) - 1;
let dDayStr;
if (dDay < 0) {
dDayStr = '모집 마감';
Expand Down
4 changes: 2 additions & 2 deletions src/utils/calculateDDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default function calculateDDay(
date2: string = 'today',
): number {
const targetDate1 = new Date(date1.replace(/Z/g, ''));
const targetData2 =
const targetDate2 =
date2 === 'today' ? new Date() : new Date(date2.replace(/Z/g, ''));
const timeDiff = targetDate1.getTime() - targetData2.getTime();
const timeDiff = targetDate1.getTime() - targetDate2.getTime();
const daysDiff = Math.ceil(timeDiff / ONE_DAY);
return daysDiff;
}
9 changes: 9 additions & 0 deletions src/utils/calculateDDayPrev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ONE_DAY from '@/constants/day';

export default function calculateDDayPrev(date: string): number {
const today = new Date();
const targetDate = new Date(date.replace(/Z/g, ''));
const timeDiff = targetDate.getTime() - today.getTime();
const daysDiff = Math.ceil(timeDiff / ONE_DAY);
return daysDiff;
}

0 comments on commit d539cda

Please sign in to comment.