Skip to content

Commit

Permalink
Allow the "ignore timezone" setting to be adjustable when parsing ISO…
Browse files Browse the repository at this point in the history
…8601 dates
  • Loading branch information
urkle authored and arshaw committed Sep 26, 2010
1 parent dc7094e commit a436ea7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/main.js
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions src/util.js
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit a436ea7

Please sign in to comment.