Index: trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js |
— | — | @@ -161,10 +161,13 @@ |
162 | 162 | |
163 | 163 | // XXX: support localization |
164 | 164 | Date.replaceChars = { |
165 | | - shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], |
166 | | - longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], |
| 165 | + shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', |
| 166 | + 'Sep', 'Oct', 'Nov', 'Dec'], |
| 167 | + longMonths: ['January', 'February', 'March', 'April', 'May', 'June', |
| 168 | + 'July', 'August', 'September', 'October', 'November', 'December'], |
167 | 169 | shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], |
168 | | - longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], |
| 170 | + longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', |
| 171 | + 'Friday', 'Saturday'], |
169 | 172 | |
170 | 173 | // Day |
171 | 174 | d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); }, |
— | — | @@ -172,43 +175,87 @@ |
173 | 176 | j: function() { return this.getDate(); }, |
174 | 177 | l: function() { return Date.replaceChars.longDays[this.getDay()]; }, |
175 | 178 | N: function() { return this.getDay() + 1; }, |
176 | | - S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); }, |
| 179 | + S: function() { |
| 180 | + return (this.getDate() % 10 == 1 && |
| 181 | + this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && |
| 182 | + this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && |
| 183 | + this.getDate() != 13 ? 'rd' : 'th'))); |
| 184 | + }, |
177 | 185 | w: function() { return this.getDay(); }, |
178 | | - z: function() { var d = new Date(this.getFullYear(),0,1); return Math.ceil((this - d) / 86400000); }, // Fixed now |
| 186 | + z: function() { |
| 187 | + var d = new Date(this.getFullYear(),0,1); |
| 188 | + return Math.ceil((this - d) / 86400000); |
| 189 | + }, |
179 | 190 | // Week |
180 | | - W: function() { var d = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); }, // Fixed now |
| 191 | + W: function() { |
| 192 | + var d = new Date(this.getFullYear(), 0, 1); |
| 193 | + return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); |
| 194 | + }, |
181 | 195 | // Month |
182 | 196 | F: function() { return Date.replaceChars.longMonths[this.getMonth()]; }, |
183 | 197 | m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); }, |
184 | 198 | M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; }, |
185 | 199 | n: function() { return this.getMonth() + 1; }, |
186 | | - t: function() { var d = new Date(); return new Date(d.getFullYear(), d.getMonth(), 0).getDate(); }, // Fixed now, gets #days of date |
| 200 | + t: function() { |
| 201 | + var d = new Date(); |
| 202 | + return new Date(d.getFullYear(), d.getMonth(), 0).getDate(); |
| 203 | + }, |
187 | 204 | // Year |
188 | | - L: function() { var year = this.getFullYear(); return (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)); }, // Fixed now |
189 | | - o: function() { var d = new Date(this.valueOf()); d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); return d.getFullYear();}, //Fixed now |
| 205 | + L: function() { |
| 206 | + var year = this.getFullYear(); |
| 207 | + return (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)); |
| 208 | + }, |
| 209 | + o: function() { |
| 210 | + var d = new Date(this.valueOf()); |
| 211 | + d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); |
| 212 | + return d.getFullYear(); |
| 213 | + }, |
190 | 214 | Y: function() { return this.getFullYear(); }, |
191 | 215 | y: function() { return ('' + this.getFullYear()).substr(2); }, |
192 | 216 | // Time |
193 | 217 | a: function() { return this.getHours() < 12 ? 'am' : 'pm'; }, |
194 | 218 | A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; }, |
195 | | - B: function() { return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24); }, // Fixed now |
| 219 | + B: function() { |
| 220 | + return Math.floor((((this.getUTCHours() + 1) % 24) + |
| 221 | + this.getUTCMinutes() / 60 + |
| 222 | + this.getUTCSeconds() / 3600) * 1000 / 24); |
| 223 | + }, |
196 | 224 | g: function() { return this.getHours() % 12 || 12; }, |
197 | 225 | G: function() { return this.getHours(); }, |
198 | | - h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); }, |
| 226 | + h: function() { |
| 227 | + return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + |
| 228 | + (this.getHours() % 12 || 12); |
| 229 | + }, |
199 | 230 | H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); }, |
200 | 231 | i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); }, |
201 | 232 | s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); }, |
202 | | - u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ? |
203 | | -'0' : '')) + m; }, |
| 233 | + u: function() { |
| 234 | + var m = this.getMilliseconds(); |
| 235 | + return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m; |
| 236 | + }, |
204 | 237 | // Timezone |
205 | 238 | e: function() { return "Not Yet Supported"; }, |
206 | 239 | I: function() { return "Not Yet Supported"; }, |
207 | | - O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; }, |
208 | | - P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; }, // Fixed now |
209 | | - T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;}, |
| 240 | + O: function() { |
| 241 | + return (-this.getTimezoneOffset() < 0 ? '-' : '+') + |
| 242 | + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + |
| 243 | + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; |
| 244 | + }, |
| 245 | + P: function() { |
| 246 | + return (-this.getTimezoneOffset() < 0 ? '-' : '+') + |
| 247 | + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + |
| 248 | + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; |
| 249 | + }, |
| 250 | + T: function() { |
| 251 | + var m = this.getMonth(); |
| 252 | + this.setMonth(0); |
| 253 | + var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); |
| 254 | + this.setMonth(m); |
| 255 | + return result; |
| 256 | + }, |
210 | 257 | Z: function() { return -this.getTimezoneOffset() * 60; }, |
211 | 258 | // Full Date/Time |
212 | | - c: function() { return this.format("Y-m-d\\TH:i:sP"); }, // Fixed now |
| 259 | + c: function() { return this.format("Y-m-d\\TH:i:sP"); }, |
213 | 260 | r: function() { return this.toString(); }, |
214 | 261 | U: function() { return this.getTime() / 1000; } |
215 | 262 | }; |