Allow the "ignore timezone" setting to be adjustable when parsing ISO8601 dates
This commit is contained in:
parent
dc7094ed27
commit
a436ea73f0
|
@ -44,6 +44,8 @@ var defaults = {
|
|||
timeFormat: { // for event elements
|
||||
'': 'h(:mm)t' // default
|
||||
},
|
||||
// ignoreTimezone for ISO8601 dates in added Events
|
||||
ignoreTimezone: true,
|
||||
|
||||
// locale
|
||||
isRTL: false,
|
||||
|
@ -894,8 +896,8 @@ function normalizeEvent(event, options) {
|
|||
}
|
||||
delete event.date;
|
||||
}
|
||||
event._start = cloneDate(event.start = parseDate(event.start));
|
||||
event.end = parseDate(event.end);
|
||||
event._start = cloneDate(event.start = parseDate(event.start, options.ignoreTimezone));
|
||||
event.end = parseDate(event.end, options.ignoreTimezone);
|
||||
if (event.end && event.end <= event.start) {
|
||||
event.end = null;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ function setYMD(date, y, m, d) {
|
|||
/* Date Parsing
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
var parseDate = fc.parseDate = function(s) {
|
||||
var parseDate = fc.parseDate = function(s, ignoreTimezone) {
|
||||
if (typeof s == 'object') { // already a Date object
|
||||
return s;
|
||||
}
|
||||
|
@ -127,7 +127,10 @@ var parseDate = fc.parseDate = function(s) {
|
|||
if (s.match(/^\d+$/)) { // a UNIX timestamp
|
||||
return new Date(parseInt(s) * 1000);
|
||||
}
|
||||
return parseISO8601(s, true) || (s ? new Date(s) : null);
|
||||
if (ignoreTimezone === undefined) {
|
||||
ignoreTimezone = true;
|
||||
}
|
||||
return parseISO8601(s, ignoreTimezone) || (s ? new Date(s) : null);
|
||||
}
|
||||
// TODO: never return invalid dates (like from new Date(<string>)), return null instead
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue