v0.0.51: 사이드바 열 높이 고정·발행일 YYYY.MM.DD 통일
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
22
composables/formatPostDate.js
Normal file
22
composables/formatPostDate.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 공개 화면용 게시 날짜를 YYYY.MM.DD 형식으로 변환한다.
|
||||
* @param {string | null | undefined} value - ISO 8601 등 파싱 가능한 날짜 문자열
|
||||
* @returns {string} 빈 문자열 또는 YYYY.MM.DD
|
||||
*/
|
||||
export function formatPostDate(value) {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const date = new Date(value)
|
||||
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
|
||||
return `${year}.${month}.${day}`
|
||||
}
|
||||
Reference in New Issue
Block a user