File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 1- function timeAgo ( createdAt : string ) {
1+ function timeAgo ( createdAt : string ) : string {
22 const createdDate = new Date ( createdAt ) ;
33 const currentDate = new Date ( ) ;
44
5- const secondsDiff = Math . floor ( ( currentDate - createdDate ) / 1000 ) ; // 초 단위 차이
6- const minutesDiff = Math . floor ( secondsDiff / 60 ) ; // 분 단위 차이
7- const hoursDiff = Math . floor ( minutesDiff / 60 ) ; // 시간 단위 차이
8- const daysDiff = Math . floor ( hoursDiff / 24 ) ; // 일 단위 차이
5+ const secondsDiff = Math . floor (
6+ ( currentDate . getTime ( ) - createdDate . getTime ( ) ) / 1000
7+ ) ;
8+ const minutesDiff = Math . floor ( secondsDiff / 60 ) ;
9+ const hoursDiff = Math . floor ( minutesDiff / 60 ) ;
10+ const daysDiff = Math . floor ( hoursDiff / 24 ) ; //
911
1012 if ( hoursDiff < 1 ) {
11- return `${ secondsDiff } 초 전` ; // 1시간 미만
13+ return `${ secondsDiff } 초 전` ;
1214 } else if ( hoursDiff < 24 ) {
13- return `${ hoursDiff } 시간 전` ; // 1일 미만
15+ return `${ hoursDiff } 시간 전` ;
1416 } else {
15- return `${ daysDiff } 일 전` ; // 1일 이상
17+ return `${ daysDiff } 일 전` ;
1618 }
1719}
1820
You can’t perform that action at this time.
0 commit comments