diff --git a/ical.js b/ical.js index 1e472bd..0298aa5 100644 --- a/ical.js +++ b/ical.js @@ -584,11 +584,8 @@ module.exports = { rule = rule.slice(rule.lastIndexOf('FREQ=')); // If no rule start date if (rule.includes('DTSTART') === false) { - // Get date/time into a specific format for comapare - let x = moment(curr.start).format('MMMM/Do/YYYY, h:mm:ss a'); - // If the local time value is midnight // This a whole day event - if (x.slice(-11) === '12:00:00 am') { + if (curr.datetype === 'date') { // Get the timezone offset // The internal date is stored in UTC format const offset = curr.start.getTimezoneOffset(); @@ -600,7 +597,7 @@ module.exports = { curr.start = new Date(curr.start.getTime() + (Math.abs(offset) * 60000)); } else { // Get rid of any time (shouldn't be any, but be sure) - x = moment(curr.start).format('MMMM/Do/YYYY'); + const x = moment(curr.start).format('MMMM/Do/YYYY'); const comps = /^(\d{2})\/(\d{2})\/(\d{4})/.exec(x); if (comps) { curr.start = new Date(comps[3], comps[1] - 1, comps[2]); diff --git a/test/germany_at_end_of_day_repeating.ics b/test/germany_at_end_of_day_repeating.ics new file mode 100644 index 0000000..04eb089 --- /dev/null +++ b/test/germany_at_end_of_day_repeating.ics @@ -0,0 +1,15 @@ +BEGIN:VCALENDAR +BEGIN:VEVENT +DTSTART;TZID=Europe/Germany:20241022T230000 +DTEND;TZID=TZID=Europe/Germany:20241023T000000 +RRULE:FREQ=DAILY;WKST=MO;COUNT=4 +DTSTAMP:20241009T153220Z +UID:2m6mt1p89l2anl74915ur3hsgm@google.com +CREATED:20241009T153058Z +LAST-MODIFIED:20241009T153205Z +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:TestCal_AllDayRepeatingEvent +TRANSP:TRANSPARENT +END:VEVENT +END:VCALENDAR \ No newline at end of file diff --git a/test/test.js b/test/test.js index 22671ff..ddff525 100644 --- a/test/test.js +++ b/test/test.js @@ -1161,6 +1161,41 @@ vows } } } + }, + 'with germany_at_end_of_day_repeating.ics': { + topic() { + return ical.parseFile('./test/germany_at_end_of_day_repeating.ics'); + }, + checkEnd: { + topic(events) { + return _.select(_.values(events), x => { + return x.uid === '2m6mt1p89l2anl74915ur3hsgm@google.com'; + })[0]; + }, + 'task completed'(task) { + assert.equal(task.start.toDateString(), new Date(2024, 9, 22, 23, 0, 0).toDateString()); + } + } + }, + 'with whole_day_moved_over_dst_change_berlin.ics': { + topic() { + return ical.parseFile('./test/whole_day_moved_over_dst_change_berlin.ics'); + }, + checkEnd: { + topic(events) { + return _.select(_.values(events), x => { + return x.uid === '14nv8jl8d6dvdbl477lod4fftf@google.com'; + })[0].recurrences['2024-10-28']; + }, + 'topic recurrence': { + 'datetype is date'(task) { + assert.equal(task.datetype, 'date'); + }, + 'moved event starts 30 Oct 2024'(now) { + assert.equal(now.start.toDateString(), new Date(2024, 9, 30, 0, 0, 0).toDateString()); + } + } + } } }) .export(module); diff --git a/test/whole_day_moved_over_dst_change_berlin.ics b/test/whole_day_moved_over_dst_change_berlin.ics new file mode 100644 index 0000000..7335ccf --- /dev/null +++ b/test/whole_day_moved_over_dst_change_berlin.ics @@ -0,0 +1,28 @@ +BEGIN:VCALENDAR +BEGIN:VEVENT +DTSTART;VALUE=DATE:20241027 +DTEND;VALUE=DATE:20241028 +RRULE:FREQ=DAILY;WKST=SU;COUNT=3 +DTSTAMP:20241020T152634Z +UID:14nv8jl8d6dvdbl477lod4fftf@google.com +CREATED:20241020T152434Z +LAST-MODIFIED:20241020T152536Z +SEQUENCE:1 +STATUS:CONFIRMED +SUMMARY:test whole day moved +TRANSP:TRANSPARENT +END:VEVENT +BEGIN:VEVENT +DTSTART;VALUE=DATE:20241030 +DTEND;VALUE=DATE:20241031 +DTSTAMP:20241020T152634Z +UID:14nv8jl8d6dvdbl477lod4fftf@google.com +RECURRENCE-ID;VALUE=DATE:20241028 +CREATED:20241020T152434Z +LAST-MODIFIED:20241020T152536Z +SEQUENCE:2 +STATUS:CONFIRMED +SUMMARY:test whole day moved +TRANSP:TRANSPARENT +END:VEVENT +END:VCALENDAR