@@ -4,6 +4,7 @@ import { useMemo } from 'react';
4
4
import { NAME_SPACE } from '../../constants/core' ;
5
5
import { IDateValue , ITimeValue , TIsVisible } from '../../types/props' ;
6
6
import { formatDate , formatDateValue } from '../../utils/datetime' ;
7
+ import { setMonthPage } from '../../utils/page' ;
7
8
8
9
interface Iprops {
9
10
type : TIsVisible ;
@@ -33,6 +34,14 @@ export default function RangepickerMonth({
33
34
const lastDate = lastDateValue . getDate ( ) ; // 이달 말 일
34
35
const lastDay = lastDateValue . getDay ( ) ; // 이달 말 일의 요일
35
36
const prevLastDate = new Date ( year , month - 1 , 0 ) . getDate ( ) ; // 이전달의 말 일
37
+ const startValue = useMemo (
38
+ ( ) => ( type === 'start' ? dateValue : pairValue ) ,
39
+ [ dateValue , pairValue , type ]
40
+ ) ;
41
+ const endValue = useMemo (
42
+ ( ) => ( type === 'end' ? dateValue : pairValue ) ,
43
+ [ dateValue , pairValue , type ]
44
+ ) ;
36
45
const formatedDateValue = useMemo (
37
46
( ) => formatDateValue ( dateValue , timeValue , valueFormat ) ,
38
47
[ dateValue , timeValue , valueFormat ]
@@ -48,6 +57,17 @@ export default function RangepickerMonth({
48
57
return type === 'end' ? formatedDateValue : formatedPairValue ;
49
58
} , [ formatedDateValue , formatedPairValue , type ] ) ;
50
59
60
+ const parsedValueToDate = ( value : IDateValue ) => {
61
+ return new Date (
62
+ - 1 ,
63
+ setMonthPage ( `${ value . year ! + 2 } -${ value . month ! } ` ) ,
64
+ value . date ! ,
65
+ timeValue . hour ,
66
+ timeValue . minute ,
67
+ timeValue . second
68
+ ) ;
69
+ } ;
70
+
51
71
const renderDateButton = (
52
72
month : number ,
53
73
date : number ,
@@ -93,10 +113,10 @@ export default function RangepickerMonth({
93
113
data-start-active = { formatedStartValue === formatedThisValue }
94
114
data-end-active = { formatedEndValue === formatedThisValue }
95
115
data-range-active = {
96
- formatedStartValue &&
97
- formatedEndValue &&
98
- buttonDate > new Date ( formatedStartValue ) &&
99
- buttonDate < new Date ( formatedEndValue )
116
+ startValue &&
117
+ endValue &&
118
+ buttonDate > parsedValueToDate ( startValue ) &&
119
+ buttonDate < parsedValueToDate ( endValue )
100
120
}
101
121
onClick = { handleClick }
102
122
>
0 commit comments