Diffstat (limited to 'frontend/beta/js/Clipperz/Date.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/Date.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/Date.js b/frontend/beta/js/Clipperz/Date.js index 020d77b..e8f7705 100644 --- a/frontend/beta/js/Clipperz/Date.js +++ b/frontend/beta/js/Clipperz/Date.js | |||
@@ -1,214 +1,212 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; } | 25 | if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; } |
28 | 26 | ||
29 | Clipperz.Date.VERSION = "0.1"; | 27 | Clipperz.Date.VERSION = "0.1"; |
30 | Clipperz.Date.NAME = "Clipperz.Date"; | 28 | Clipperz.Date.NAME = "Clipperz.Date"; |
31 | 29 | ||
32 | MochiKit.Base.update(Clipperz.Date, { | 30 | MochiKit.Base.update(Clipperz.Date, { |
33 | 31 | ||
34 | //------------------------------------------------------------------------- | 32 | //------------------------------------------------------------------------- |
35 | 33 | ||
36 | '__repr__': function () { | 34 | '__repr__': function () { |
37 | return "[" + this.NAME + " " + this.VERSION + "]"; | 35 | return "[" + this.NAME + " " + this.VERSION + "]"; |
38 | }, | 36 | }, |
39 | 37 | ||
40 | //------------------------------------------------------------------------- | 38 | //------------------------------------------------------------------------- |
41 | 39 | ||
42 | 'toString': function () { | 40 | 'toString': function () { |
43 | return this.__repr__(); | 41 | return this.__repr__(); |
44 | }, | 42 | }, |
45 | 43 | ||
46 | //------------------------------------------------------------------------- | 44 | //------------------------------------------------------------------------- |
47 | 45 | ||
48 | 'daysInMonth': [31,28,31,30,31,30,31,31,30,31,30,31], | 46 | 'daysInMonth': [31,28,31,30,31,30,31,31,30,31,30,31], |
49 | 47 | ||
50 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
51 | 49 | ||
52 | 'englishOrdinalDaySuffixForDate': function(aDate) { | 50 | 'englishOrdinalDaySuffixForDate': function(aDate) { |
53 | var result; | 51 | var result; |
54 | 52 | ||
55 | switch (aDate.getDate()) { | 53 | switch (aDate.getDate()) { |
56 | case 1: | 54 | case 1: |
57 | case 21: | 55 | case 21: |
58 | case 31: | 56 | case 31: |
59 | result = "st"; | 57 | result = "st"; |
60 | break; | 58 | break; |
61 | case 2: | 59 | case 2: |
62 | case 22: | 60 | case 22: |
63 | result = "nd"; | 61 | result = "nd"; |
64 | break; | 62 | break; |
65 | case 3: | 63 | case 3: |
66 | case 23: | 64 | case 23: |
67 | result = "rd"; | 65 | result = "rd"; |
68 | break; | 66 | break; |
69 | default: | 67 | default: |
70 | result = "th"; | 68 | result = "th"; |
71 | break; | 69 | break; |
72 | } | 70 | } |
73 | 71 | ||
74 | return result; | 72 | return result; |
75 | }, | 73 | }, |
76 | 74 | ||
77 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
78 | 76 | ||
79 | 'isLeapYear': function(aDate) { | 77 | 'isLeapYear': function(aDate) { |
80 | var year; | 78 | var year; |
81 | var result; | 79 | var result; |
82 | 80 | ||
83 | year = aDate.getFullYear(); | 81 | year = aDate.getFullYear(); |
84 | result = ((year & 0x03) == 0 && (year % 100 || (year % 400 == 0 && year))); | 82 | result = ((year & 0x03) == 0 && (year % 100 || (year % 400 == 0 && year))); |
85 | 83 | ||
86 | return result; | 84 | return result; |
87 | }, | 85 | }, |
88 | 86 | ||
89 | //------------------------------------------------------------------------- | 87 | //------------------------------------------------------------------------- |
90 | 88 | ||
91 | 'getDaysInMonth': function(aDate) { | 89 | 'getDaysInMonth': function(aDate) { |
92 | var result; | 90 | var result; |
93 | 91 | ||
94 | if (aDate.getMonth() == 1) { | 92 | if (aDate.getMonth() == 1) { |
95 | Clipperz.Date.isLeapYear(aDate) | 93 | Clipperz.Date.isLeapYear(aDate) |
96 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; | 94 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; |
97 | } else { | 95 | } else { |
98 | result = Clipperz.Date.daysInMonth[aDate.getMonth()]; | 96 | result = Clipperz.Date.daysInMonth[aDate.getMonth()]; |
99 | } | 97 | } |
100 | 98 | ||
101 | return result; | 99 | return result; |
102 | }, | 100 | }, |
103 | 101 | ||
104 | //------------------------------------------------------------------------- | 102 | //------------------------------------------------------------------------- |
105 | 103 | ||
106 | 'getTimezone': function(aDate) { | 104 | 'getTimezone': function(aDate) { |
107 | var result; | 105 | var result; |
108 | 106 | ||
109 | result = aDate.toString(); | 107 | result = aDate.toString(); |
110 | result = result.replace(/([A-Z]{3}) [0-9]{4}/, '$1'); | 108 | result = result.replace(/([A-Z]{3}) [0-9]{4}/, '$1'); |
111 | result = result.replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3"); | 109 | result = result.replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3"); |
112 | 110 | ||
113 | return result; | 111 | return result; |
114 | }, | 112 | }, |
115 | 113 | ||
116 | 'getGMTOffset': function(aDate) { | 114 | 'getGMTOffset': function(aDate) { |
117 | return (aDate.getTimezoneOffset() > 0 ? "-" : "+")+ MochiKit.Format.numberFormatter('00')(Math.floor(this.getTimezoneOffset() / 60)) | 115 | return (aDate.getTimezoneOffset() > 0 ? "-" : "+")+ MochiKit.Format.numberFormatter('00')(Math.floor(this.getTimezoneOffset() / 60)) |
118 | + MochiKit.Format.numberFormatter('00')(this.getTimezoneOffset() % 60); | 116 | + MochiKit.Format.numberFormatter('00')(this.getTimezoneOffset() % 60); |
119 | }, | 117 | }, |
120 | 118 | ||
121 | //------------------------------------------------------------------------- | 119 | //------------------------------------------------------------------------- |
122 | 120 | ||
123 | 'dayOfYear': function(aDate) { | 121 | 'dayOfYear': function(aDate) { |
124 | var result; | 122 | var result; |
125 | var i,c; | 123 | var i,c; |
126 | 124 | ||
127 | result = 0; | 125 | result = 0; |
128 | c = aDate.getMonth(); | 126 | c = aDate.getMonth(); |
129 | for (i=0; i<c; i++) { | 127 | for (i=0; i<c; i++) { |
130 | if (i == 1) { | 128 | if (i == 1) { |
131 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; | 129 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; |
132 | } else { | 130 | } else { |
133 | result += Clipperz.Date.daysInMonth[i]; | 131 | result += Clipperz.Date.daysInMonth[i]; |
134 | } | 132 | } |
135 | } | 133 | } |
136 | return num + this.getDate() - 1; | 134 | return num + this.getDate() - 1; |
137 | }, | 135 | }, |
138 | 136 | ||
139 | //------------------------------------------------------------------------- | 137 | //------------------------------------------------------------------------- |
140 | 138 | ||
141 | 'getPHPLikeFormatCode': function(aCharacter) { | 139 | 'getPHPLikeFormatCode': function(aCharacter) { |
142 | var result; | 140 | var result; |
143 | 141 | ||
144 | switch (aCharacter) { | 142 | switch (aCharacter) { |
145 | case "d": | 143 | case "d": |
146 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getDate())"; | 144 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getDate())"; |
147 | break; | 145 | break; |
148 | case "D": | 146 | case "D": |
149 | result = " + aLocale['shortDays'][aDate.getDay()]"; | 147 | result = " + aLocale['shortDays'][aDate.getDay()]"; |
150 | break; | 148 | break; |
151 | case "j": | 149 | case "j": |
152 | result = " + aDate.getDate()"; | 150 | result = " + aDate.getDate()"; |
153 | break; | 151 | break; |
154 | case "l": | 152 | case "l": |
155 | result = " + aLocale['days'][aDate.getDay()]"; | 153 | result = " + aLocale['days'][aDate.getDay()]"; |
156 | break; | 154 | break; |
157 | case "S": | 155 | case "S": |
158 | result = " + Clipperz.Date.englishOrdinalDaySuffixForDate(aDate)"; | 156 | result = " + Clipperz.Date.englishOrdinalDaySuffixForDate(aDate)"; |
159 | break; | 157 | break; |
160 | case "w": | 158 | case "w": |
161 | result = " + aDate.getDay()"; | 159 | result = " + aDate.getDay()"; |
162 | break; | 160 | break; |
163 | case "z": | 161 | case "z": |
164 | result = " + aDate.getDayOfYear()"; | 162 | result = " + aDate.getDayOfYear()"; |
165 | break; | 163 | break; |
166 | case "W": | 164 | case "W": |
167 | result = " + aDate.getWeekOfYear()"; | 165 | result = " + aDate.getWeekOfYear()"; |
168 | break; | 166 | break; |
169 | case "F": | 167 | case "F": |
170 | result = " + aLocale['months'][aDate.getMonth()]"; | 168 | result = " + aLocale['months'][aDate.getMonth()]"; |
171 | break; | 169 | break; |
172 | case "m": | 170 | case "m": |
173 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getMonth() + 1)"; | 171 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getMonth() + 1)"; |
174 | break; | 172 | break; |
175 | case "M": | 173 | case "M": |
176 | result = " + aLocale['shortMonths'][aDate.getMonth()]"; | 174 | result = " + aLocale['shortMonths'][aDate.getMonth()]"; |
177 | break; | 175 | break; |
178 | case "n": | 176 | case "n": |
179 | result = " + (aDate.getMonth() + 1)"; | 177 | result = " + (aDate.getMonth() + 1)"; |
180 | break; | 178 | break; |
181 | case "t": | 179 | case "t": |
182 | result = " + Clipperz.Date.getDaysInMonth(aDate)"; | 180 | result = " + Clipperz.Date.getDaysInMonth(aDate)"; |
183 | break; | 181 | break; |
184 | case "L": | 182 | case "L": |
185 | result = " + (Clipperz.Date.isLeapYear(aDate) ? 1 : 0)"; | 183 | result = " + (Clipperz.Date.isLeapYear(aDate) ? 1 : 0)"; |
186 | break; | 184 | break; |
187 | case "Y": | 185 | case "Y": |
188 | result = " + aDate.getFullYear()"; | 186 | result = " + aDate.getFullYear()"; |
189 | break; | 187 | break; |
190 | case "y": | 188 | case "y": |
191 | result = " + ('' + aDate.getFullYear()).substring(2, 4)"; | 189 | result = " + ('' + aDate.getFullYear()).substring(2, 4)"; |
192 | break; | 190 | break; |
193 | case "a": | 191 | case "a": |
194 | result = " + (aDate.getHours() < 12 ? aLocale['amDesignation'] : aLocale['pmDesignation'])"; | 192 | result = " + (aDate.getHours() < 12 ? aLocale['amDesignation'] : aLocale['pmDesignation'])"; |
195 | break; | 193 | break; |
196 | case "A": | 194 | case "A": |
197 | result = " + (aDate.getHours() < 12 ? aLocale['amDesignation'].toUpperCase() : aLocale['pmDesignation'].toUpperCase())"; | 195 | result = " + (aDate.getHours() < 12 ? aLocale['amDesignation'].toUpperCase() : aLocale['pmDesignation'].toUpperCase())"; |
198 | break; | 196 | break; |
199 | case "g": | 197 | case "g": |
200 | result = " + ((aDate.getHours() %12) ? aDate.getHours() % 12 : 12)"; | 198 | result = " + ((aDate.getHours() %12) ? aDate.getHours() % 12 : 12)"; |
201 | break; | 199 | break; |
202 | case "G": | 200 | case "G": |
203 | result = " + aDate.getHours()"; | 201 | result = " + aDate.getHours()"; |
204 | break; | 202 | break; |
205 | case "h": | 203 | case "h": |
206 | result = " + MochiKit.Format.numberFormatter('00')((aDate.getHours() %12) ? aDate.getHours() % 12 : 12)"; | 204 | result = " + MochiKit.Format.numberFormatter('00')((aDate.getHours() %12) ? aDate.getHours() % 12 : 12)"; |
207 | break; | 205 | break; |
208 | case "H": | 206 | case "H": |
209 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getHours())"; | 207 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getHours())"; |
210 | break; | 208 | break; |
211 | case "i": | 209 | case "i": |
212 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getMinutes())"; | 210 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getMinutes())"; |
213 | break; | 211 | break; |
214 | case "s": | 212 | case "s": |