Skip to content

Commit

Permalink
refactor: get format time 함수 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
Jungjjeong committed Aug 2, 2024
1 parent f0937a6 commit 92ba780
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ type GetTime = {
*/
export const getFormatTime = ({ timeStr, type = 'number' }: GetTime) => {
const [hour, minute, second] = timeStr.split(':');
const hourNum = parseInt(hour, 10);
const minuteNum = parseInt(minute, 10);
const secondNum = parseInt(second, 10);

const isTypeNumber = type === 'number';

return {
hour: isTypeNumber ? hourNum : hour,
minute: isTypeNumber ? minuteNum : minute,
second: isTypeNumber ? secondNum : second,
hour: isTypeNumber ? parseInt(hour, 10) : hour,
minute: isTypeNumber ? parseInt(minute, 10) : minute,
second: isTypeNumber ? parseInt(second, 10) : second,
};
};

0 comments on commit 92ba780

Please sign in to comment.