author | Giulio 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) |
commit | 928f3f3ed3981f7f81b69ed94f2a315205db39fa (patch) (unidiff) | |
tree | 8a47229b56e4c906de8512baf0c5ca100bc03dfb /frontend/gamma/js/MochiKit/DateTime.js | |
parent | bf7d8191a3a6dbd092a88911098a3e7f6cf30cf7 (diff) | |
download | clipperz-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) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/MochiKit/DateTime.js | 49 |
1 files changed, 26 insertions, 23 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 | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('DateTime', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'DateTime', '1.5', ['Base']); |
12 | 12 | ||
13 | /** @id MochiKit.DateTime.isoDate */ | 13 | /** @id MochiKit.DateTime.isoDate */ |
14 | MochiKit.DateTime.isoDate = function (str) { | 14 | MochiKit.DateTime.isoDate = function (str) { |
15 | str = str + ""; | 15 | str = str + ""; |
@@ -19,12 +19,12 @@ MochiKit.DateTime.isoDate = function (str) { | |||
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 | ||
30 | 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}))?)?)?)?)?/; | 30 | 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}))?)?)?)?)?/; |
@@ -79,39 +79,42 @@ MochiKit.DateTime.isoTimestamp = function (str) { | |||
79 | MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { | 79 | MochiKit.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 */ |
95 | MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { | 97 | MochiKit.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 */ |
108 | MochiKit.DateTime.toISODate = function (date) { | 111 | MochiKit.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), |
117 | _padTwo(date.getDate()) | 120 | _padTwo(date.getDate()) |
@@ -132,16 +135,16 @@ MochiKit.DateTime._padTwo = function (n) { | |||
132 | return (n > 9) ? n : "0" + n; | 135 | return (n > 9) ? n : "0" + n; |
133 | }; | 136 | }; |
134 | 137 | ||
135 | MochiKit.DateTime._padFour = function(n) { | 138 | MochiKit.DateTime._padFour = function(n) { |
136 | switch(n.toString().length) { | 139 | switch(n.toString().length) { |
137 | case 1: return "000" + n; break; | 140 | case 1: return "000" + n; break; |
138 | case 2: return "00" + n; break; | 141 | case 2: return "00" + n; break; |
139 | case 3: return "0" + n; break; | 142 | case 3: return "0" + n; break; |
140 | case 4: | 143 | case 4: |
141 | default: | 144 | default: |
142 | return n; | 145 | return n; |
143 | } | 146 | } |
144 | }; | 147 | }; |
145 | 148 | ||
146 | /** @id MochiKit.DateTime.toPaddedAmericanDate */ | 149 | /** @id MochiKit.DateTime.toPaddedAmericanDate */ |
147 | MochiKit.DateTime.toPaddedAmericanDate = function (d) { | 150 | MochiKit.DateTime.toPaddedAmericanDate = function (d) { |