summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/DateTime.js
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2012-03-17 21:08:23 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2012-03-17 21:08:23 (UTC)
commit928f3f3ed3981f7f81b69ed94f2a315205db39fa (patch) (unidiff)
tree8a47229b56e4c906de8512baf0c5ca100bc03dfb /frontend/gamma/js/MochiKit/DateTime.js
parentbf7d8191a3a6dbd092a88911098a3e7f6cf30cf7 (diff)
downloadclipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.zip
clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.gz
clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.bz2
Fixed frontend properties and updated MochiKit version
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,35 +1,35 @@
1/*** 1/***
2 2
3MochiKit.DateTime 1.5 3MochiKit.DateTime 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('DateTime', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'DateTime', '1.5', ['Base']);
12 12
13/** @id MochiKit.DateTime.isoDate */ 13/** @id MochiKit.DateTime.isoDate */
14MochiKit.DateTime.isoDate = function (str) { 14MochiKit.DateTime.isoDate = function (str) {
15 str = str + ""; 15 str = str + "";
16 if (typeof(str) != "string" || str.length === 0) { 16 if (typeof(str) != "string" || str.length === 0) {
17 return null; 17 return null;
18 } 18 }
19 var iso = str.split('-'); 19 var iso = str.split('-');
20 if (iso.length === 0) { 20 if (iso.length === 0) {
21 return null; 21 return null;
22 } 22 }
23 var date = new Date(iso[0], iso[1] - 1, iso[2]); 23 var date = new Date(parseInt(iso[0], 10), parseInt(iso[1], 10) - 1, parseInt(iso[2], 10));
24 date.setFullYear(iso[0]); 24 date.setFullYear(iso[0]);
25 date.setMonth(iso[1] - 1); 25 date.setMonth(iso[1] - 1);
26 date.setDate(iso[2]); 26 date.setDate(iso[2]);
27 return date; 27 return date;
28}; 28};
29 29
30MochiKit.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}))?)?)?)?)?/; 30MochiKit.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}))?)?)?)?)?/;
31 31
32/** @id MochiKit.DateTime.isoTimestamp */ 32/** @id MochiKit.DateTime.isoTimestamp */
33MochiKit.DateTime.isoTimestamp = function (str) { 33MochiKit.DateTime.isoTimestamp = function (str) {
34 str = str + ""; 34 str = str + "";
35 if (typeof(str) != "string" || str.length === 0) { 35 if (typeof(str) != "string" || str.length === 0) {
@@ -71,46 +71,49 @@ MochiKit.DateTime.isoTimestamp = function (str) {
71 } 71 }
72 } else { 72 } else {
73 ofs = 0; 73 ofs = 0;
74 } 74 }
75 return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs); 75 return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs);
76}; 76};
77 77
78/** @id MochiKit.DateTime.toISOTime */ 78/** @id MochiKit.DateTime.toISOTime */
79MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { 79MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) {
80 if (typeof(date) == "undefined" || date === null) { 80 if (typeof(date) == "undefined" || date === null) {
81 return null; 81 return null;
82 } 82 }
83 var hh = date.getHours(); 83 var _padTwo = MochiKit.DateTime._padTwo;
84 var mm = date.getMinutes(); 84 if (realISO) {
85 var ss = date.getSeconds(); 85 // adjust date for UTC timezone
86 date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
87 }
86 var lst = [ 88 var lst = [
87 ((realISO && (hh < 10)) ? "0" + hh : hh), 89 (realISO ? _padTwo(date.getHours()) : date.getHours()),
88 ((mm < 10) ? "0" + mm : mm), 90 _padTwo(date.getMinutes()),
89 ((ss < 10) ? "0" + ss : ss) 91 _padTwo(date.getSeconds())
90 ]; 92 ];
91 return lst.join(":"); 93 return lst.join(":") + (realISO ? "Z" : "");
92}; 94};
93 95
94/** @id MochiKit.DateTime.toISOTimeStamp */ 96/** @id MochiKit.DateTime.toISOTimeStamp */
95MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { 97MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) {
96 if (typeof(date) == "undefined" || date === null) { 98 if (typeof(date) == "undefined" || date === null) {
97 return null; 99 return null;
98 } 100 }
101 var time = MochiKit.DateTime.toISOTime(date, realISO);
99 var sep = realISO ? "T" : " "; 102 var sep = realISO ? "T" : " ";
100 var foot = realISO ? "Z" : "";
101 if (realISO) { 103 if (realISO) {
104 // adjust date for UTC timezone
102 date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); 105 date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
103 } 106 }
104 return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot; 107 return MochiKit.DateTime.toISODate(date) + sep + time;
105}; 108};
106 109
107/** @id MochiKit.DateTime.toISODate */ 110/** @id MochiKit.DateTime.toISODate */
108MochiKit.DateTime.toISODate = function (date) { 111MochiKit.DateTime.toISODate = function (date) {
109 if (typeof(date) == "undefined" || date === null) { 112 if (typeof(date) == "undefined" || date === null) {
110 return null; 113 return null;
111 } 114 }
112 var _padTwo = MochiKit.DateTime._padTwo; 115 var _padTwo = MochiKit.DateTime._padTwo;
113 var _padFour = MochiKit.DateTime._padFour; 116 var _padFour = MochiKit.DateTime._padFour;
114 return [ 117 return [
115 _padFour(date.getFullYear()), 118 _padFour(date.getFullYear()),
116 _padTwo(date.getMonth() + 1), 119 _padTwo(date.getMonth() + 1),