fix. 날짜 표기 형식 @seed-next로 수정
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { globalDateFormat } from '@seed-next/date'
|
||||
import { PREREGIST_ERROR_CODE } from '#layers/composables/usePreregist'
|
||||
|
||||
interface Props {
|
||||
@@ -358,7 +359,7 @@ defineExpose({
|
||||
<p
|
||||
class="text-[13px] font-normal leading-[22px] tracking-[-0.325px] text-[#b2b2b2] opacity-50 md:text-[15px] md:leading-6 md:tracking-[-0.45px]"
|
||||
>
|
||||
{{ preregistDate }}
|
||||
{{ globalDateFormat(preregistDate, locale) }}
|
||||
</p>
|
||||
<h3
|
||||
class="text-xl font-bold leading-[30px] tracking-[-0.6px] text-[#ebebeb] md:text-2xl md:leading-[34px] md:tracking-[-0.72px]"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { SplideSlide } from '@splidejs/vue-splide'
|
||||
import { globalDateFormat } from '@seed-next/date'
|
||||
import {
|
||||
getComponentGroup,
|
||||
getComponentContainer,
|
||||
} from '#layers/utils/dataUtil'
|
||||
import { getYouTubeThumbnail } from '#layers/utils/youtubeUtil'
|
||||
import { formatTimestamp } from '#layers/utils/formatUtil'
|
||||
import type { Splide as SplideType } from '@splidejs/splide'
|
||||
import type { PageDataTemplateComponents } from '#layers/types/api/pageData'
|
||||
import type { OperateGroupItem } from '#layers/types/api/resourcesData'
|
||||
@@ -165,7 +165,7 @@ const handleLoadMoreRecent = () => {
|
||||
<p
|
||||
class="mt-2 text-[14px] leading-[24px] tracking-[-0.42px] text-[#999] sm:mt-3.5 md:mt-4 md:text-[18px] md:font-[500] md:leading-[26px] md:tracking-[-0.54px] lg:mt-5 lg:text-[20px] lg:leading-[30px] lg:tracking-[-0.6px]"
|
||||
>
|
||||
{{ formatTimestamp(item.reg_dt, 'YYYY.MM.DD') }}
|
||||
{{ globalDateFormat(item.reg_dt, locale) }}
|
||||
</p>
|
||||
</div>
|
||||
</SplideSlide>
|
||||
@@ -209,7 +209,7 @@ const handleLoadMoreRecent = () => {
|
||||
<p
|
||||
class="mt-2 text-[14px] leading-[24px] tracking-[-0.42px] text-[#999] md:text-[16px] md:leading-[26px] md:tracking-[-0.48px]"
|
||||
>
|
||||
{{ formatTimestamp(item.reg_dt, 'YYYY.MM.DD') }}
|
||||
{{ globalDateFormat(item.reg_dt, locale) }}
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { SplideSlide } from '@splidejs/vue-splide'
|
||||
import { globalDateFormat } from '@seed-next/date'
|
||||
import { getComponentGroup } from '#layers/utils/dataUtil'
|
||||
import type { PageDataTemplateComponents } from '#layers/types/api/pageData'
|
||||
import type { CwmsArticleItem } from '#layers/types/api/resourcesData'
|
||||
@@ -137,9 +138,7 @@ const onArrowClick = (direction, targetIndex) => {
|
||||
<div class="slide-inner">
|
||||
<BlocksCardNews
|
||||
:title="item.title"
|
||||
:description="
|
||||
formatTimestamp(item.create_datetime, 'YYYY.MM.DD')
|
||||
"
|
||||
:description="globalDateFormat(item.create_datetime, locale)"
|
||||
:img-path="getImageHost(item.media_thumbnail_url)"
|
||||
:url="getArticleUrl(item.article_id)"
|
||||
link-target="_blank"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { SplideSlide } from '@splidejs/vue-splide'
|
||||
import { globalDateFormat } from '@seed-next/date'
|
||||
import {
|
||||
getComponentGroup,
|
||||
getComponentContainer,
|
||||
} from '#layers/utils/dataUtil'
|
||||
import { formatTimestamp } from '#layers/utils/formatUtil'
|
||||
import { getImageHost } from '#layers/utils/styleUtil'
|
||||
import type { PageDataTemplateComponents } from '#layers/types/api/pageData'
|
||||
import type { OperateGroupItem } from '#layers/types/api/resourcesData'
|
||||
@@ -117,7 +117,7 @@ const onArrowClick = direction => {
|
||||
<SplideSlide v-for="(item, index) in slideData" :key="index">
|
||||
<BlocksCardNews
|
||||
:title="item.title"
|
||||
:description="formatTimestamp(item.reg_dt, 'YYYY.MM.DD')"
|
||||
:description="globalDateFormat(item.reg_dt, locale)"
|
||||
:img-path="getImageHost(item.img_path)"
|
||||
:url="item.url"
|
||||
:link-target="item.link_target"
|
||||
|
||||
@@ -24,76 +24,6 @@ export const csrFormatJWT = (base64EncodeVal: string) => {
|
||||
return decodeVal
|
||||
}
|
||||
|
||||
/**
|
||||
* 타임스탬프를 다양한 날짜 형식으로 변환합니다.
|
||||
* @param timestamp 타임스탬프 (밀리초 또는 초)
|
||||
* @param format 날짜 형식 ('YYYY-MM-DD', 'YYYY-MM-DD HH:mm:ss', 'MM/DD/YYYY', 'YYYY년 MM월 DD일' 등)
|
||||
* @param locale 로케일 (기본값: 'ko-KR')
|
||||
* @returns 포맷된 날짜 문자열
|
||||
*/
|
||||
export const formatTimestamp = (
|
||||
timestamp: number | string,
|
||||
format: string = 'YYYY.MM.DD',
|
||||
_locale: string = 'ko-KR'
|
||||
): string => {
|
||||
if (!timestamp) return ''
|
||||
|
||||
// 타임스탬프를 숫자로 변환
|
||||
let ts = typeof timestamp === 'string' ? parseInt(timestamp) : timestamp
|
||||
|
||||
// 초 단위인 경우 밀리초로 변환
|
||||
if (ts < 10000000000) {
|
||||
ts = ts * 1000
|
||||
}
|
||||
|
||||
const date = new Date(ts)
|
||||
|
||||
// 유효하지 않은 날짜인 경우 빈 문자열 반환
|
||||
if (isNaN(date.getTime())) {
|
||||
return ''
|
||||
}
|
||||
|
||||
// 미리 정의된 형식들
|
||||
const predefinedFormats: Record<string, string> = {
|
||||
'YYYY.MM.DD': date.toISOString().split('T')[0].replace(/-/g, '.'),
|
||||
'YYYY-MM-DD': date.toISOString().split('T')[0],
|
||||
'YYYY-MM-DD HH:mm': date.toISOString().replace('T', ' ').substring(0, 16),
|
||||
'YYYY-MM-DD HH:mm:ss': date.toISOString().replace('T', ' ').split('.')[0],
|
||||
'MM/DD/YYYY': date.toLocaleDateString('en-US'),
|
||||
'DD/MM/YYYY': date.toLocaleDateString('en-GB'),
|
||||
'YYYY년 MM월 DD일': date.toLocaleDateString('ko-KR', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}),
|
||||
'MM월 DD일': date.toLocaleDateString('ko-KR', {
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}),
|
||||
}
|
||||
|
||||
// 미리 정의된 형식이 있으면 사용
|
||||
if (predefinedFormats[format]) {
|
||||
return predefinedFormats[format]
|
||||
}
|
||||
|
||||
// 커스텀 형식 처리
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||
|
||||
return format
|
||||
.replace('YYYY', String(year))
|
||||
.replace('MM', month)
|
||||
.replace('DD', day)
|
||||
.replace('HH', hours)
|
||||
.replace('mm', minutes)
|
||||
.replace('ss', seconds)
|
||||
}
|
||||
|
||||
/**
|
||||
* 배열 또는 객체를 배열로 변환합니다.
|
||||
* @param value 변환할 값 (배열, 객체, 또는 undefined/null)
|
||||
|
||||
Reference in New Issue
Block a user