Diffstat (limited to 'frontend/gamma/js/MochiKit/DateTime.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/js/MochiKit/DateTime.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/frontend/gamma/js/MochiKit/DateTime.js b/frontend/gamma/js/MochiKit/DateTime.js index c7b2d25..658084c 100644 --- a/frontend/gamma/js/MochiKit/DateTime.js +++ b/frontend/gamma/js/MochiKit/DateTime.js @@ -1,35 +1,35 @@ /*** MochiKit.DateTime 1.5 See <http://mochikit.com/> for documentation, downloads, license, etc. (c) 2005 Bob Ippolito. All rights Reserved. ***/ -MochiKit.Base._module('DateTime', '1.5', ['Base']); +MochiKit.Base.module(MochiKit, 'DateTime', '1.5', ['Base']); /** @id MochiKit.DateTime.isoDate */ MochiKit.DateTime.isoDate = function (str) { str = str + ""; if (typeof(str) != "string" || str.length === 0) { return null; } var iso = str.split('-'); if (iso.length === 0) { return null; } - var date = new Date(iso[0], iso[1] - 1, iso[2]); + var date = new Date(parseInt(iso[0], 10), parseInt(iso[1], 10) - 1, parseInt(iso[2], 10)); date.setFullYear(iso[0]); date.setMonth(iso[1] - 1); date.setDate(iso[2]); return date; }; MochiKit.DateTime._isoRegexp = /(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/; /** @id MochiKit.DateTime.isoTimestamp */ MochiKit.DateTime.isoTimestamp = function (str) { str = str + ""; if (typeof(str) != "string" || str.length === 0) { @@ -71,46 +71,49 @@ MochiKit.DateTime.isoTimestamp = function (str) { } } else { ofs = 0; } return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs); }; /** @id MochiKit.DateTime.toISOTime */ MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { if (typeof(date) == "undefined" || date === null) { return null; } - var hh = date.getHours(); - var mm = date.getMinutes(); - var ss = date.getSeconds(); + var _padTwo = MochiKit.DateTime._padTwo; + if (realISO) { + // adjust date for UTC timezone + date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); + } var lst = [ - ((realISO && (hh < 10)) ? "0" + hh : hh), - ((mm < 10) ? "0" + mm : mm), - ((ss < 10) ? "0" + ss : ss) + (realISO ? _padTwo(date.getHours()) : date.getHours()), + _padTwo(date.getMinutes()), + _padTwo(date.getSeconds()) ]; - return lst.join(":"); + return lst.join(":") + (realISO ? "Z" : ""); }; /** @id MochiKit.DateTime.toISOTimeStamp */ MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { if (typeof(date) == "undefined" || date === null) { return null; } + var time = MochiKit.DateTime.toISOTime(date, realISO); var sep = realISO ? "T" : " "; - var foot = realISO ? "Z" : ""; if (realISO) { + // adjust date for UTC timezone date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); } - return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot; + return MochiKit.DateTime.toISODate(date) + sep + time; }; /** @id MochiKit.DateTime.toISODate */ MochiKit.DateTime.toISODate = function (date) { if (typeof(date) == "undefined" || date === null) { return null; } var _padTwo = MochiKit.DateTime._padTwo; var _padFour = MochiKit.DateTime._padFour; return [ _padFour(date.getFullYear()), _padTwo(date.getMonth() + 1), |