Skip to content

Commit 2b90200

Browse files
committed
apply coderabbitai suggestions.
1 parent b66b57b commit 2b90200

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ical.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -458,22 +458,23 @@ module.exports = {
458458
curr.end = (curr.datetype === 'date-time') ? new Date(curr.start.getTime()) : moment.utc(curr.start).add(1, 'days').toDate();
459459

460460
// If there was a duration specified
461+
// see RFC5545, 3.3.6 (no year and month)
461462
if (curr.duration !== undefined) {
462463
const durationUnits =
463464
{
464-
// Y: 'years',
465-
// M: 'months',
466465
W: 'weeks',
467466
D: 'days',
468467
H: 'hours',
469468
M: 'minutes',
470469
S: 'seconds'
471470
};
472471
// Get the list of duration elements
473-
const duration = curr.duration.match(/-?\d{1,10}[YMWDHS]/g);
472+
const duration = curr.duration.match(/-?\d{1,10}[WDHMS]/g);
474473

475474
// Use the duration to create the end value, from the start
476-
let newEnd = moment.utc(curr.start);
475+
const startMoment = moment.utc(curr.start);
476+
let newEnd = startMoment;
477+
477478
// Is the 1st character a negative sign?
478479
const indicator = curr.duration.startsWith('-') ? -1 : 1;
479480

0 commit comments

Comments
 (0)