##// END OF EJS Templates
web: Output a correct date in short format (issue2902)
Benoit Allard -
r14881:2e543879 stable
parent child Browse files
Show More
@@ -160,13 +160,31 b' process_dates = (function(document, RegE'
160 if (count > 1){
160 if (count > 1){
161 ret = ret + 's';
161 ret = ret + 's';
162 }
162 }
163 return ret;
164 }
165
166 function shortdate(date){
167 var ret = date.getFullYear() + '-';
168 // getMonth() gives a 0-11 result
169 var month = date.getMonth() + 1;
170 if (month <= 9){
171 ret += '0' + month;
172 } else {
173 ret += month;
174 }
175 ret += '-';
176 var day = date.getDate();
177 if (day <= 9){
178 ret += '0' + day;
179 } else {
180 ret += day;
181 }
163 return ret;
182 return ret;
164 }
183 }
165
184
166 function age(datestr){
185 function age(datestr){
167 var now = new Date();
186 var now = new Date();
168 var once = new Date(datestr);
187 var once = new Date(datestr);
169
170 if (isNaN(once.getTime())){
188 if (isNaN(once.getTime())){
171 // parsing error
189 // parsing error
172 return datestr;
190 return datestr;
@@ -184,7 +202,7 b' process_dates = (function(document, RegE'
184 }
202 }
185
203
186 if (delta > (2 * scales.year)){
204 if (delta > (2 * scales.year)){
187 return once.getFullYear() + '-' + once.getMonth() + '-' + once.getDate();
205 return shortdate(once);
188 }
206 }
189
207
190 for (unit in scales){
208 for (unit in scales){
General Comments 0
You need to be logged in to leave comments. Login now