comparison iso8601.js @ 29:e007a6364bf0

Fix an error when loading file/directory.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 01 Nov 2010 09:18:54 +0100
parents 7cfcd7d5796c
children 5395a501c991
comparison
equal deleted inserted replaced
28:7cfcd7d5796c 29:e007a6364bf0
16 * You should have received a copy of the GNU Affero General Public License 16 * You should have received a copy of the GNU Affero General Public License
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. 17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20 Date.prototype.setFromISO8601 = function(iso){ 20 Date.prototype.setFromISO8601 = function(iso){
21 var format = /(\d\{4\})(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)Z/; 21 var format = /(\d{4})(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)Z/;
22 var m = iso.match(format); 22 var m = iso.match(format);
23 23
24 this.setUTCDate(1); 24 this.setUTCDate(1);
25 this.setUTCFullYear(parseInt(m[1],10)); 25 this.setUTCFullYear(parseInt(m[1]));
26 this.setUTCMonth(parseInt(m[3],10) - 1); 26 this.setUTCMonth(parseInt(m[3],10) - 1);
27 this.setUTCDate(parseInt(m[5],10)); 27 this.setUTCDate(parseInt(m[5],10));
28 this.setUTCHours(parseInt(m[7],10)); 28 this.setUTCHours(parseInt(m[7],10));
29 this.setUTCMinutes(parseInt(m[9],10)); 29 this.setUTCMinutes(parseInt(m[9],10));
30 this.setUTCSeconds(parseInt(m[11],10)); 30 this.setUTCSeconds(parseInt(m[11],10));