Diffstat (limited to 'frontend/beta/js/Clipperz/Date.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/Date.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/Date.js b/frontend/beta/js/Clipperz/Date.js index 4103b88..020d77b 100644 --- a/frontend/beta/js/Clipperz/Date.js +++ b/frontend/beta/js/Clipperz/Date.js | |||
@@ -1,152 +1,149 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; } | 27 | if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; } |
31 | 28 | ||
32 | Clipperz.Date.VERSION = "0.1"; | 29 | Clipperz.Date.VERSION = "0.1"; |
33 | Clipperz.Date.NAME = "Clipperz.Date"; | 30 | Clipperz.Date.NAME = "Clipperz.Date"; |
34 | 31 | ||
35 | MochiKit.Base.update(Clipperz.Date, { | 32 | MochiKit.Base.update(Clipperz.Date, { |
36 | 33 | ||
37 | //------------------------------------------------------------------------- | 34 | //------------------------------------------------------------------------- |
38 | 35 | ||
39 | '__repr__': function () { | 36 | '__repr__': function () { |
40 | return "[" + this.NAME + " " + this.VERSION + "]"; | 37 | return "[" + this.NAME + " " + this.VERSION + "]"; |
41 | }, | 38 | }, |
42 | 39 | ||
43 | //------------------------------------------------------------------------- | 40 | //------------------------------------------------------------------------- |
44 | 41 | ||
45 | 'toString': function () { | 42 | 'toString': function () { |
46 | return this.__repr__(); | 43 | return this.__repr__(); |
47 | }, | 44 | }, |
48 | 45 | ||
49 | //------------------------------------------------------------------------- | 46 | //------------------------------------------------------------------------- |
50 | 47 | ||
51 | 'daysInMonth': [31,28,31,30,31,30,31,31,30,31,30,31], | 48 | 'daysInMonth': [31,28,31,30,31,30,31,31,30,31,30,31], |
52 | 49 | ||
53 | //------------------------------------------------------------------------- | 50 | //------------------------------------------------------------------------- |
54 | 51 | ||
55 | 'englishOrdinalDaySuffixForDate': function(aDate) { | 52 | 'englishOrdinalDaySuffixForDate': function(aDate) { |
56 | var result; | 53 | var result; |
57 | 54 | ||
58 | switch (aDate.getDate()) { | 55 | switch (aDate.getDate()) { |
59 | case 1: | 56 | case 1: |
60 | case 21: | 57 | case 21: |
61 | case 31: | 58 | case 31: |
62 | result = "st"; | 59 | result = "st"; |
63 | break; | 60 | break; |
64 | case 2: | 61 | case 2: |
65 | case 22: | 62 | case 22: |
66 | result = "nd"; | 63 | result = "nd"; |
67 | break; | 64 | break; |
68 | case 3: | 65 | case 3: |
69 | case 23: | 66 | case 23: |
70 | result = "rd"; | 67 | result = "rd"; |
71 | break; | 68 | break; |
72 | default: | 69 | default: |
73 | result = "th"; | 70 | result = "th"; |
74 | break; | 71 | break; |
75 | } | 72 | } |
76 | 73 | ||
77 | return result; | 74 | return result; |
78 | }, | 75 | }, |
79 | 76 | ||
80 | //------------------------------------------------------------------------- | 77 | //------------------------------------------------------------------------- |
81 | 78 | ||
82 | 'isLeapYear': function(aDate) { | 79 | 'isLeapYear': function(aDate) { |
83 | var year; | 80 | var year; |
84 | var result; | 81 | var result; |
85 | 82 | ||
86 | year = aDate.getFullYear(); | 83 | year = aDate.getFullYear(); |
87 | result = ((year & 0x03) == 0 && (year % 100 || (year % 400 == 0 && year))); | 84 | result = ((year & 0x03) == 0 && (year % 100 || (year % 400 == 0 && year))); |
88 | 85 | ||
89 | return result; | 86 | return result; |
90 | }, | 87 | }, |
91 | 88 | ||
92 | //------------------------------------------------------------------------- | 89 | //------------------------------------------------------------------------- |
93 | 90 | ||
94 | 'getDaysInMonth': function(aDate) { | 91 | 'getDaysInMonth': function(aDate) { |
95 | var result; | 92 | var result; |
96 | 93 | ||
97 | if (aDate.getMonth() == 1) { | 94 | if (aDate.getMonth() == 1) { |
98 | Clipperz.Date.isLeapYear(aDate) | 95 | Clipperz.Date.isLeapYear(aDate) |
99 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; | 96 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; |
100 | } else { | 97 | } else { |
101 | result = Clipperz.Date.daysInMonth[aDate.getMonth()]; | 98 | result = Clipperz.Date.daysInMonth[aDate.getMonth()]; |
102 | } | 99 | } |
103 | 100 | ||
104 | return result; | 101 | return result; |
105 | }, | 102 | }, |
106 | 103 | ||
107 | //------------------------------------------------------------------------- | 104 | //------------------------------------------------------------------------- |
108 | 105 | ||
109 | 'getTimezone': function(aDate) { | 106 | 'getTimezone': function(aDate) { |
110 | var result; | 107 | var result; |
111 | 108 | ||
112 | result = aDate.toString(); | 109 | result = aDate.toString(); |
113 | result = result.replace(/([A-Z]{3}) [0-9]{4}/, '$1'); | 110 | result = result.replace(/([A-Z]{3}) [0-9]{4}/, '$1'); |
114 | result = result.replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3"); | 111 | result = result.replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3"); |
115 | 112 | ||
116 | return result; | 113 | return result; |
117 | }, | 114 | }, |
118 | 115 | ||
119 | 'getGMTOffset': function(aDate) { | 116 | 'getGMTOffset': function(aDate) { |
120 | return (aDate.getTimezoneOffset() > 0 ? "-" : "+")+ MochiKit.Format.numberFormatter('00')(Math.floor(this.getTimezoneOffset() / 60)) | 117 | return (aDate.getTimezoneOffset() > 0 ? "-" : "+")+ MochiKit.Format.numberFormatter('00')(Math.floor(this.getTimezoneOffset() / 60)) |
121 | + MochiKit.Format.numberFormatter('00')(this.getTimezoneOffset() % 60); | 118 | + MochiKit.Format.numberFormatter('00')(this.getTimezoneOffset() % 60); |
122 | }, | 119 | }, |
123 | 120 | ||
124 | //------------------------------------------------------------------------- | 121 | //------------------------------------------------------------------------- |
125 | 122 | ||
126 | 'dayOfYear': function(aDate) { | 123 | 'dayOfYear': function(aDate) { |
127 | var result; | 124 | var result; |
128 | var i,c; | 125 | var i,c; |
129 | 126 | ||
130 | result = 0; | 127 | result = 0; |
131 | c = aDate.getMonth(); | 128 | c = aDate.getMonth(); |
132 | for (i=0; i<c; i++) { | 129 | for (i=0; i<c; i++) { |
133 | if (i == 1) { | 130 | if (i == 1) { |
134 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; | 131 | result += Clipperz.Date.isLeapYear(aDate) ? 29 : 28; |
135 | } else { | 132 | } else { |
136 | result += Clipperz.Date.daysInMonth[i]; | 133 | result += Clipperz.Date.daysInMonth[i]; |
137 | } | 134 | } |
138 | } | 135 | } |
139 | return num + this.getDate() - 1; | 136 | return num + this.getDate() - 1; |
140 | }, | 137 | }, |
141 | 138 | ||
142 | //------------------------------------------------------------------------- | 139 | //------------------------------------------------------------------------- |
143 | 140 | ||
144 | 'getPHPLikeFormatCode': function(aCharacter) { | 141 | 'getPHPLikeFormatCode': function(aCharacter) { |
145 | var result; | 142 | var result; |
146 | 143 | ||
147 | switch (aCharacter) { | 144 | switch (aCharacter) { |
148 | case "d": | 145 | case "d": |
149 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getDate())"; | 146 | result = " + MochiKit.Format.numberFormatter('00')(aDate.getDate())"; |
150 | break; | 147 | break; |
151 | case "D": | 148 | case "D": |
152 | result = " + aLocale['shortDays'][aDate.getDay()]"; | 149 | result = " + aLocale['shortDays'][aDate.getDay()]"; |