ical.js
ical.js copied to clipboard
Time.adjust doesn't respect timezone
require('ical.js');
var wintertime = new ICAL.Component('standard');
wintertime.addPropertyWithValue('dtstart', new ICAL.Time({
year: 1996,
month: 10,
day: 27,
hour: 3
}));
wintertime.addPropertyWithValue('tzoffsetfrom', '+02:00');
wintertime.addPropertyWithValue('tzoffsetto', '+01:00');
wintertime.addPropertyWithValue('rrule', new ICAL.Recur({
freq: 'YEARLY',
bymonth: 10,
byday: '-1SU'
}));
var summertime = new ICAL.Component('daylight');
summertime.addPropertyWithValue('dtstart', new ICAL.Time({
year: 1996,
month: 3,
day: 31,
hour: 2
}));
summertime.addPropertyWithValue('tzoffsetfrom', '+01:00');
summertime.addPropertyWithValue('tzoffsetto', '+02:00');
summertime.addPropertyWithValue('rrule', new ICAL.Recur({
freq: 'YEARLY',
bymonth: 3,
byday: '-1SU'
}));
var tzComp = new ICAL.Component('vtimezone');
tzComp.addPropertyWithValue('tzid', 'Europe/Stockholm');
tzComp.addSubcomponent(wintertime);
tzComp.addSubcomponent(summertime);
t = new ICAL.Time({ year: 2017, month: 3, day: 26, hour: 1, minute: 0}, tzComp);
t.adjust(0, 1, 0, 0);
console.log(t.toICALString());
This prints 20170326T020000, which is a time that does not exist, it should
be 20170326T030000.
Just as an example, this is the behaviour I'm expecting to see:
> moment('2017-03-26T01:00:00').add(1, 'hours')
moment("2017-03-26T03:00:00.000")
What about using addDuration instead? The adjust method is mostly used internally.
Changing it to:
t.addDuration(new ICAL.Duration({ hours: 1 }));
Does not change the resulting time
Moreover, I would argue no method (unless very explicitly documented) should yield times that doesn't exist.
It looks like we haven't heard back on this issue, therefore we are closing this issue. If this problem persists in the latest version of ical.js, please re-open this issue.
This probably should not have been closed as info has been provided.