summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/DateTime.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/MochiKit/DateTime.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/MochiKit/DateTime.js25
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,47 +1,47 @@
/***
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) {
return null;
}
var res = str.match(MochiKit.DateTime._isoRegexp);
if (typeof(res) == "undefined" || res === null) {
return null;
}
var year, month, day, hour, min, sec, msec;
year = parseInt(res[1], 10);
if (typeof(res[2]) == "undefined" || res[2] === '') {
return new Date(year);
}
month = parseInt(res[2], 10) - 1;
@@ -59,70 +59,73 @@ MochiKit.DateTime.isoTimestamp = function (str) {
}
if ((typeof(res[8]) == "undefined" || res[8] === '') && (typeof(res[9]) == "undefined" || res[9] === '')) {
return new Date(year, month, day, hour, min, sec, msec);
}
var ofs;
if (typeof(res[9]) != "undefined" && res[9] !== '') {
ofs = parseInt(res[10], 10) * 3600000;
if (typeof(res[11]) != "undefined" && res[11] !== '') {
ofs += parseInt(res[11], 10) * 60000;
}
if (res[9] == "-") {
ofs = -ofs;
}
} 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),
_padTwo(date.getDate())
].join("-");
};
/** @id MochiKit.DateTime.americanDate */
MochiKit.DateTime.americanDate = function (d) {
d = d + "";
if (typeof(d) != "string" || d.length === 0) {
return null;
}
var a = d.split('/');
return new Date(a[2], a[0] - 1, a[1]);