Skip to content

Commit

Permalink
πŸ”¨ refactor: λ‚ μ§œ 포맷 ν•¨μˆ˜ formatDate λ¦¬νŒ©ν† λ§
Browse files Browse the repository at this point in the history
  • Loading branch information
easyhyun00 committed Jan 27, 2024
1 parent 2eddc15 commit a394dc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/Accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useRef } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import DownArrow from '@/assets/icons/downArrow.svg?react';
import formatDate from '@/utils/dateUtils';
import { inboxDate, sendDate } from '@/utils/dateUtils';
import useCheckTextLines from '@/hooks/useCheckTextLines';
import style, { accordionType } from './styles';

Expand Down Expand Up @@ -46,7 +46,9 @@ const Accordion = ({
textContainerRef={textContainerRef}
{...props}
/>
<p css={style.date(type)}>{formatDate(date)}</p>
<p css={style.date(type)}>
{type === 'inbox' ? inboxDate(date) : sendDate(date)}
</p>
{showButton && (
<Bottom isOpen={isOpen} toggleAccordion={toggleAccordion} />
)}
Expand Down
14 changes: 11 additions & 3 deletions src/utils/dateUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const formatDate = (date: Date) => {
const formatDate = (date: Date): string => {
const year = date.getFullYear().toString().substring(2, 4);
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');

return `${year}λ…„ ${month}μ›” ${day}일에 받은 νŽΈμ§€`;
return `${year}λ…„ ${month}μ›” ${day}일`;
};

export default formatDate;
const inboxDate = (date: Date): string => {
return `${formatDate(date)}에 받은 νŽΈμ§€`;
};

const sendDate = (date: Date): string => {
return formatDate(date);
};

export { inboxDate, sendDate };

0 comments on commit a394dc1

Please sign in to comment.