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