11'use client' ;
22
3+ import dayjs from 'dayjs' ;
34import { ComponentProps } from 'react' ;
5+
46import { MissionListResponse } from '@/api/openapi/models' ;
57import Badge from '@/components/ui/badge' ;
68import Button from '@/components/ui/button' ;
@@ -42,9 +44,8 @@ const STATUS_CONFIG = {
4244
4345function formatDate ( dateString ?: string ) {
4446 if ( ! dateString ) return '' ;
45- const date = new Date ( dateString ) ;
4647
47- return ` ${ date . getFullYear ( ) } - ${ String ( date . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) } - ${ String ( date . getDate ( ) ) . padStart ( 2 , '0' ) } ` ;
48+ return dayjs ( dateString ) . format ( 'YYYY-MM-DD' ) ;
4849}
4950
5051function getDeadlineInfo ( endDate ?: string ) : {
@@ -53,15 +54,13 @@ function getDeadlineInfo(endDate?: string): {
5354} | null {
5455 if ( ! endDate ) return null ;
5556
56- const now = new Date ( ) ;
57- const end = new Date ( endDate ) ;
58- end . setHours ( 23 , 59 , 59 , 999 ) ;
57+ const now = dayjs ( ) ;
58+ const end = dayjs ( endDate ) . endOf ( 'day' ) ;
5959
60- const diffMs = end . getTime ( ) - now . getTime ( ) ;
61- if ( diffMs < 0 ) return null ;
60+ if ( end . isBefore ( now ) ) return null ;
6261
63- const diffHours = diffMs / ( 1000 * 60 * 60 ) ;
64- const diffDays = Math . ceil ( diffMs / ( 1000 * 60 * 60 * 24 ) ) ;
62+ const diffHours = end . diff ( now , 'hour' ) ;
63+ const diffDays = Math . ceil ( end . diff ( now , 'day' , true ) ) ;
6564
6665 if ( diffHours <= 24 ) {
6766 return { text : '오늘 제출 마감' , isUrgent : true } ;
0 commit comments