@@ -111,23 +111,14 @@ const SUPPORTED_BY_DAY_WEEKLY = [
111
111
'SA' ,
112
112
]
113
113
114
- /**
115
- * Get all numbers between start and end as strings
116
- *
117
- * @param {number } start Lower end of range
118
- * @param {number } end Upper end of range
119
- * @return {string[] }
120
- */
121
- const getRangeAsStrings = ( start , end ) => {
122
- return Array
123
- . apply ( null , Array ( ( end - start ) + 1 ) )
124
- . map ( ( _ , n ) => n + start )
125
- . map ( ( s ) => s . toString ( ) )
126
- }
127
-
128
- const SUPPORTED_BY_MONTHDAY_MONTHLY = getRangeAsStrings ( 1 , 31 )
114
+ const SUPPORTED_BY_MONTHDAY_MONTHLY = [
115
+ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ,
116
+ 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 ,
117
+ 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 ,
118
+ 31
119
+ ]
129
120
130
- const SUPPORTED_BY_MONTH_YEARLY = getRangeAsStrings ( 1 , 12 )
121
+ const SUPPORTED_BY_MONTH_YEARLY = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ]
131
122
132
123
/**
133
124
* Maps a daily calendar-js recurrence-rule-value to an recurrence-rule-object
@@ -230,12 +221,12 @@ const mapMonthlyRuleValueToRecurrenceRuleObject = (recurrenceRuleValue, baseDate
230
221
}
231
222
232
223
const containsInvalidByMonthDay = recurrenceRuleValue . getComponent ( 'BYMONTHDAY' )
233
- . some ( ( monthDay ) => ! SUPPORTED_BY_MONTHDAY_MONTHLY . includes ( monthDay . toString ( ) ) )
224
+ . some ( ( monthDay ) => ! SUPPORTED_BY_MONTHDAY_MONTHLY . includes ( parseInt ( monthDay ) ) )
234
225
isUnsupported = isUnsupported || containsInvalidByMonthDay
235
226
236
227
byMonthDay = recurrenceRuleValue . getComponent ( 'BYMONTHDAY' )
237
- . filter ( ( monthDay ) => SUPPORTED_BY_MONTHDAY_MONTHLY . includes ( monthDay . toString ( ) ) )
238
- . map ( ( monthDay ) => monthDay . toString ( ) )
228
+ . filter ( ( monthDay ) => SUPPORTED_BY_MONTHDAY_MONTHLY . includes ( parseInt ( monthDay ) ) )
229
+ . map ( ( monthDay ) => parseInt ( monthDay ) )
239
230
240
231
// This handles cases where we have both BYDAY and BYSETPOS
241
232
} else if ( containsRecurrenceComponent ( recurrenceRuleValue , [ 'BYDAY' ] ) && containsRecurrenceComponent ( recurrenceRuleValue , [ 'BYSETPOS' ] ) ) {
@@ -332,14 +323,14 @@ const mapYearlyRuleValueToRecurrenceRuleObject = (recurrenceRuleValue, baseDate)
332
323
333
324
if ( containsRecurrenceComponent ( recurrenceRuleValue , [ 'BYMONTH' ] ) ) {
334
325
const containsInvalidByMonthDay = recurrenceRuleValue . getComponent ( 'BYMONTH' )
335
- . some ( ( month ) => ! SUPPORTED_BY_MONTH_YEARLY . includes ( month . toString ( ) ) )
326
+ . some ( ( month ) => ! SUPPORTED_BY_MONTH_YEARLY . includes ( parseInt ( month ) ) )
336
327
isUnsupported = isUnsupported || containsInvalidByMonthDay
337
328
338
329
byMonth = recurrenceRuleValue . getComponent ( 'BYMONTH' )
339
- . filter ( ( monthDay ) => SUPPORTED_BY_MONTH_YEARLY . includes ( monthDay . toString ( ) ) )
340
- . map ( ( month ) => month . toString ( ) )
330
+ . filter ( ( month ) => SUPPORTED_BY_MONTH_YEARLY . includes ( parseInt ( month ) ) )
331
+ . map ( ( month ) => parseInt ( month ) )
341
332
} else {
342
- byMonth . push ( baseDate . month . toString ( ) )
333
+ byMonth . push ( baseDate . month )
343
334
}
344
335
345
336
if ( containsRecurrenceComponent ( recurrenceRuleValue , [ 'BYDAY' ] ) && containsRecurrenceComponent ( recurrenceRuleValue , [ 'BYSETPOS' ] ) ) {
0 commit comments