Mercurial > psgxs
annotate iso8601.js @ 53:ca17b63f561f
Fix auto-subscribe of owner.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 07 Apr 2011 17:12:07 +0200 |
parents | 023f767662d3 |
children | fd69d35cf2e6 |
rev | line source |
---|---|
0 | 1 /* |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
3 * |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
4 * This file is part of PSĜS, a PubSub server written in JavaScript. |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
5 * |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
6 * PSĜS is free software: you can redistribute it and/or modify |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
7 * it under the terms of the GNU Affero General Public License as |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
9 * License. |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
10 * |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
11 * PSĜS is distributed in the hope that it will be useful, |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
14 * GNU Affero General Public License for more details. |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
15 * |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
16 * You should have received a copy of the GNU Affero General Public License |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 */ |
19 | |
43
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
38
diff
changeset
|
20 'use strict'; |
023f767662d3
Fix compatibility with strict mode of node 0.4 and some files without licence header.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
38
diff
changeset
|
21 |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
22 Date.prototype.setFromISO8601 = function(iso){ |
29
e007a6364bf0
Fix an error when loading file/directory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
28
diff
changeset
|
23 var format = /(\d{4})(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)Z/; |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
24 var m = iso.match(format); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
25 |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
26 this.setUTCDate(1); |
29
e007a6364bf0
Fix an error when loading file/directory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
28
diff
changeset
|
27 this.setUTCFullYear(parseInt(m[1])); |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
28 this.setUTCMonth(parseInt(m[3],10) - 1); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
29 this.setUTCDate(parseInt(m[5],10)); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
30 this.setUTCHours(parseInt(m[7],10)); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
31 this.setUTCMinutes(parseInt(m[9],10)); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
32 this.setUTCSeconds(parseInt(m[11],10)); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
33 this.setUTCMilliseconds(0); |
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
34 |
0 | 35 return this; |
36 }; | |
37 | |
28
7cfcd7d5796c
Replace Paul Sowden’s ISO8601 functions by my own, since their licence is possibly incompatible with AGPL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
0
diff
changeset
|
38 Date.prototype.toString = function () { |
38
5395a501c991
Use internal toISOString method of Data.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
29
diff
changeset
|
39 return this.toISOString().replace(/\....Z$/, 'Z'); |
0 | 40 }; |