This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
forked from prgrms-web-devcourse/team-angelbaby-jungdam-fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from jung-dam-diary/develop
v1.0.2 HOTFIX
- Loading branch information
Showing
13 changed files
with
201 additions
and
64 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
11 changes: 6 additions & 5 deletions
11
src/common/utils/getTodayDate.jsx → src/common/utils/getDateStr.jsx
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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
const getTodayDate = () => { | ||
let today = new Date(); | ||
const getDateStr = (date) => { | ||
let today = new Date(date); | ||
|
||
let dd = today.getDate(); | ||
let mm = today.getMonth() + 1; | ||
let yyyy = today.getFullYear(); | ||
|
||
if (dd < 10) { | ||
dd += '0'; | ||
dd = '0' + dd; | ||
} | ||
|
||
if (mm < 10) { | ||
mm += '0'; | ||
mm = '0' + mm; | ||
} | ||
|
||
today = `${yyyy}-${mm}-${dd}`; | ||
|
||
return today; | ||
}; | ||
|
||
export default getTodayDate; | ||
export default getDateStr; |
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,41 @@ | ||
const getDateValidate = (date) => { | ||
let checkDate = new Date(date); | ||
let today = new Date(); | ||
|
||
let dd1 = checkDate.getDate(); | ||
let mm1 = checkDate.getMonth() + 1; | ||
let yyyy1 = checkDate.getFullYear(); | ||
|
||
let dd2 = today.getDate(); | ||
let mm2 = today.getMonth() + 1; | ||
let yyyy2 = today.getFullYear(); | ||
console.log(dd1); | ||
console.log(mm1); | ||
if (dd1 < 10) { | ||
dd1 = '0' + dd1; | ||
} | ||
|
||
if (mm1 < 10) { | ||
mm1 = '0' + mm1; | ||
} | ||
|
||
if (dd2 < 10) { | ||
dd2 = '0' + dd2; | ||
} | ||
|
||
if (mm2 < 10) { | ||
mm2 = '0' + mm1; | ||
} | ||
|
||
checkDate = `${yyyy1}-${mm1}-${dd1}`; | ||
today = `${yyyy2}-${mm2}-${dd2}`; | ||
console.log(checkDate); | ||
console.log(today); | ||
// 지정 날짜가 현재 날짜 보다 크면 에러 발생 유도 | ||
const result = checkDate > today; | ||
console.log(result); | ||
|
||
return result; | ||
}; | ||
|
||
export default getDateValidate; |
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
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
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
Oops, something went wrong.