mirror of https://github.com/xwiki-labs/cryptpad
Fix wrong event start/end time in calendar on Daylight Saving Time days
This commit is contained in:
parent
7b86af5ac4
commit
e24703e4e6
|
@ -105,6 +105,8 @@ define([
|
|||
var startDate = event.start._date;
|
||||
var endDate = event.end._date;
|
||||
|
||||
var timeZone;
|
||||
try { timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; } catch (e) {}
|
||||
var data = {
|
||||
id: Util.uid(),
|
||||
calendarId: event.calendarId,
|
||||
|
@ -115,7 +117,8 @@ define([
|
|||
isAllDay: event.isAllDay,
|
||||
end: +endDate,
|
||||
reminders: reminders,
|
||||
recurrenceRule: event.recurrenceRule
|
||||
recurrenceRule: event.recurrenceRule,
|
||||
timeZone: timeZone
|
||||
};
|
||||
|
||||
APP.module.execCommand('CREATE_EVENT', data, function (obj) {
|
||||
|
|
|
@ -590,25 +590,14 @@ define([
|
|||
|
||||
// Return the difference in timestamps, as minutes (60*1000)
|
||||
return -(utcDate - date);
|
||||
}
|
||||
};
|
||||
|
||||
var myTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
var offset = getOffset(origin, evTimeZone) - getOffset(target, evTimeZone);
|
||||
var myOffset = getOffset(origin, myTimeZone) - getOffset(target, myTimeZone);
|
||||
|
||||
return offset - myOffset;
|
||||
return myOffset - offset;
|
||||
};
|
||||
/*
|
||||
XXX to test
|
||||
var first = new Date(2023, 09, 10, 15)
|
||||
var second = new Date(2023, 09, 30, 15)
|
||||
fixTimeZone('America/New_York', first, second) ==> should return +1h
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Rec.getRecurring = function (months, events) {
|
||||
if (window.CP_DEV_MODE) { debug = console.warn; }
|
||||
|
@ -767,6 +756,11 @@ XXX to test
|
|||
}
|
||||
|
||||
// Add this event
|
||||
if (_origin.timeZone && !_ev.isAllDay) {
|
||||
var offset = fixTimeZone(_origin.timeZone, _start, _evS);
|
||||
_ev.start += offset;
|
||||
_ev.end += offset;
|
||||
}
|
||||
toAdd.push(_ev);
|
||||
if (newrule) {
|
||||
useNewRule();
|
||||
|
|
|
@ -8,10 +8,10 @@ define([
|
|||
'/customize/messages.js',
|
||||
'/components/nthen/index.js',
|
||||
'chainpad-listmap',
|
||||
'/lib/calendar/date-picker.js',
|
||||
'/lib/datepicker/flatpickr.js',
|
||||
'/components/chainpad-crypto/crypto.js',
|
||||
'/components/chainpad/chainpad.dist.js',
|
||||
], function (Util, Hash, Constants, Realtime, Cache, Rec, Messages, nThen, Listmap, DatePicker, Crypto, ChainPad) {
|
||||
], function (Util, Hash, Constants, Realtime, Cache, Rec, Messages, nThen, Listmap, FP, Crypto, ChainPad) {
|
||||
var Calendar = {};
|
||||
|
||||
var getStore = function (ctx, id) {
|
||||
|
@ -132,9 +132,9 @@ define([
|
|||
var last = ctx.store.data.lastVisit;
|
||||
|
||||
if (ev.isAllDay) {
|
||||
if (ev.startDay) { ev.start = +DatePicker.parseDate(ev.startDay); }
|
||||
if (ev.startDay) { ev.start = +FP.parseDate(ev.startDay); }
|
||||
if (ev.endDay) {
|
||||
var endDate = DatePicker.parseDate(ev.endDay);
|
||||
var endDate = FP.parseDate(ev.endDay);
|
||||
endDate.setHours(23);
|
||||
endDate.setMinutes(59);
|
||||
endDate.setSeconds(59);
|
||||
|
|
|
@ -5,6 +5,11 @@ define([
|
|||
|
||||
'css!/lib/datepicker/flatpickr.min.css',
|
||||
], function ($, Flatpickr, Moment) {
|
||||
|
||||
var parseDate = (value) => {
|
||||
return Moment(value, 'YYYY-MM-DD HH:mm a').toDate();
|
||||
};
|
||||
|
||||
var createRangePicker = function (cfg) {
|
||||
var start = cfg.startpicker;
|
||||
var end = cfg.endpicker;
|
||||
|
@ -16,10 +21,6 @@ define([
|
|||
} catch (e) {}
|
||||
if (!is24h) { dateFormat = "Y-m-d h:i K"; }
|
||||
|
||||
var parseDate = (value) => {
|
||||
return Moment(value, 'YYYY-MM-DD HH:mm a').toDate();
|
||||
};
|
||||
|
||||
var e = $(end.input)[0];
|
||||
var endPickr = Flatpickr(e, {
|
||||
enableTime: true,
|
||||
|
|
Loading…
Reference in New Issue