File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 2929
3030<script setup lang="ts">
3131import { getCategoryColor } from " @/constants/colors" ;
32+ import { formatDate } from " @/utils/date" ;
3233import type { Post } from " @/models/PostModel" ;
3334import " ./PostCard.css" ;
3435
@@ -38,19 +39,6 @@ interface Props {
3839
3940defineProps <Props >();
4041
41- // 날짜 포맷팅 함수 (yyyy-mm-dd 형식)
42- function formatDate(dateString : string ) {
43- const date = new Date (dateString );
44- return date
45- .toLocaleDateString (" ko-KR" , {
46- year: " numeric" ,
47- month: " 2-digit" ,
48- day: " 2-digit" ,
49- })
50- .replace (/ \. / g , " -" )
51- .replace (/ \. $ / , " " );
52- }
53-
5442function navigateToPost(url : string ) {
5543 window .location .href = url ;
5644}
Original file line number Diff line number Diff line change 1+ export function formatDate ( dateString : string ) : string {
2+ const options : Intl . DateTimeFormatOptions = {
3+ year : "numeric" ,
4+ month : "long" ,
5+ day : "numeric" ,
6+ } ;
7+ const date = new Date ( dateString ) ;
8+ return date . toLocaleDateString ( undefined , options ) ;
9+ }
You can’t perform that action at this time.
0 commit comments