@@ -28,71 +28,6 @@ import {
28
28
transformDate ,
29
29
} from '../../src/utils/date' ;
30
30
31
- const orderDate = (
32
- date : string ,
33
- format : string ,
34
- isRange ?: boolean
35
- ) : { formatSeparator : string | undefined ; formattedDate : string } => {
36
- const formatRegex = / [ ^ \p{ L} ] + / gu;
37
- const dateRegex = / [ ^ \d ] + / g;
38
-
39
- const formatValueDate = ( value : string ) : string =>
40
- value . replace ( / [ a - z A - Z , ] + / , '' ) . replace ( / \s / g, '' ) ;
41
-
42
- const formattedValue = formatValueDate ( date ) ;
43
-
44
- // we want always this YYYY-MM-DD format
45
- const formatToOrderDate = 'YYYY-MM-DD' ;
46
-
47
- const correctOrder = formatToOrderDate . split ( '-' ) ;
48
-
49
- const newFormat =
50
- format . length > 8
51
- ? format
52
- : `${ format . slice ( 0 , 2 ) } -${ format . slice ( 2 , 4 ) } -${ format . slice ( 4 ) } ` ;
53
-
54
- // to get separator
55
- const formatSeparator = newFormat . match ( formatRegex ) ?. [ 0 ] ;
56
-
57
- const formatSplit = newFormat . split ( formatRegex ) ;
58
-
59
- let dateToCheck : string [ ] = [ ] ;
60
-
61
- let formattedDate = '' ;
62
-
63
- // Transform date into YYYY-MM-DD format
64
- const splitDate = ( date ) => {
65
- return correctOrder . map ( ( element : string ) => {
66
- if ( element . includes ( 'Y' ) ) {
67
- return date [ formatSplit . findIndex ( ( x : string ) => x . includes ( 'Y' ) ) ] ;
68
- } else if ( element . includes ( 'M' ) ) {
69
- return date [ formatSplit . findIndex ( ( x : string ) => x . includes ( 'M' ) ) ] ;
70
- } else if ( element . includes ( 'D' ) ) {
71
- return date [ formatSplit . findIndex ( ( x : string ) => x . includes ( 'D' ) ) ] ;
72
- }
73
- } ) ;
74
- } ;
75
-
76
- if ( formattedValue . length === newFormat . length ) {
77
- const dateSplit = formattedValue . split ( dateRegex ) ;
78
-
79
- dateToCheck = splitDate ( dateSplit ) ;
80
-
81
- formattedDate = dateToCheck . join ( '-' ) ;
82
- } else if ( isRange && date . length > newFormat . length ) {
83
- const dateRangeSplit = date . split ( dateRegex ) ;
84
- //just take the second date to check
85
- const secondDate = dateRangeSplit . splice ( 3 , 5 ) ;
86
- dateToCheck = splitDate ( secondDate ) ;
87
- formattedDate = dateToCheck . join ( '-' ) ;
88
- }
89
-
90
- return {
91
- formatSeparator,
92
- formattedDate,
93
- } ;
94
- } ;
95
-
96
31
const link = React . forwardRef ( ( props : IGenericLink , ref : unknown ) => {
97
32
return (
98
33
< a
@@ -136,10 +71,7 @@ export const ThemeProvider = ({ children, theme, themeName = 'kubit' }) => {
136
71
isBefore : ( date1 : Date , date2 : Date ) => {
137
72
return isBefore ( date1 , date2 ) ;
138
73
} ,
139
- isDatesEqual : (
140
- firsDate : string | number | Date ,
141
- secondDate : string | number | Date
142
- ) => {
74
+ isDatesEqual : ( firsDate : string | number | Date , secondDate : string | number | Date ) => {
143
75
return isDatesEqual ( firsDate , secondDate ) ;
144
76
} ,
145
77
getAddDays : ( date : Date , days : number ) => {
0 commit comments