summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/Date.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Clipperz/Date.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/Date.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/Date.js b/frontend/gamma/js/Clipperz/Date.js
index 4103b88..020d77b 100644
--- a/frontend/gamma/js/Clipperz/Date.js
+++ b/frontend/gamma/js/Clipperz/Date.js
@@ -1,120 +1,117 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer 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
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; } 27if (typeof(Clipperz.Date) == 'undefined') { Clipperz.Date = {}; }
31 28
32Clipperz.Date.VERSION = "0.1"; 29Clipperz.Date.VERSION = "0.1";
33Clipperz.Date.NAME = "Clipperz.Date"; 30Clipperz.Date.NAME = "Clipperz.Date";
34 31
35MochiKit.Base.update(Clipperz.Date, { 32MochiKit.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))