Mercurial > psgxs
annotate iso8601.js @ 33:62cbb1c49bc5
Fix publish; add owner metadata field; add HTTP module and Atom HTTP module.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 05 Nov 2010 14:01:45 +0100 |
parents | e007a6364bf0 |
children | 5395a501c991 |
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 | |
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
|
20 Date.prototype.setFromISO8601 = function(iso){ |
29
e007a6364bf0
Fix an error when loading file/directory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
28
diff
changeset
|
21 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
|
22 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
|
23 |
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 this.setUTCDate(1); |
29
e007a6364bf0
Fix an error when loading file/directory.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
28
diff
changeset
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 |
0 | 33 return this; |
34 }; | |
35 | |
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
|
36 Date.prototype.toString = function () { |
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
|
37 var pad = function (n) { |
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 return ((n < 10)? '0': '') + n; |
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
|
39 }; |
0 | 40 |
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
|
41 return this.getUTCFullYear() + |
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
|
42 "-" + pad(this.getUTCMonth() + 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
|
43 "-" + pad(this.getUTCDate()) + |
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
|
44 "T" + pad(this.getUTCHours()) + |
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
|
45 ":" + pad(this.getUTCMinutes()) + |
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
|
46 ":" + pad(this.getUTCSeconds()) + 'Z'; |
0 | 47 }; |