[PATCH stable] web: Correct calculation of the shortdate (issue2902)
Benoît Allard
benoit at aeteurope.nl
Fri Jul 15 08:24:49 UTC 2011
# HG changeset patch
# User Benoit Allard <benoit at aeteurope.nl>
# Date 1310717904 -7200
# Branch stable
# Node ID c37d8c377a1073560ca49fbd808434b7e7a377ea
# Parent 29d324c2bc930b135fd6ee8cc82d1fc29b7a8b08
web: Output a correct date in short format (issue2902)
diff -r 29d324c2bc93 -r c37d8c377a10 mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js Wed Jul 13 19:30:09 2011 -0500
+++ b/mercurial/templates/static/mercurial.js Fri Jul 15 10:18:24 2011 +0200
@@ -163,6 +163,25 @@
return ret;
}
+ function shortdate(date){
+ var ret = date.getFullYear() + '-';
+ // getMonth() gives a 0-11 result
+ var month = date.getMonth() + 1;
+ if (month <= 9){
+ ret += '0' + month;
+ } else {
+ ret += month;
+ }
+ ret += '-';
+ var day = date.getDate();
+ if (day <= 9){
+ ret += '0' + day;
+ } else {
+ ret += day;
+ }
+ return ret;
+ }
+
function age(datestr){
var now = new Date();
var once = new Date(datestr);
@@ -184,7 +203,7 @@
}
if (delta > (2 * scales.year)){
- return once.getFullYear() + '-' + once.getMonth() + '-' +
once.getDate();
+ return shortdate(once);
}
for (unit in scales){
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4936 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20110715/ab430c64/attachment.p7s>
More information about the Mercurial-devel
mailing list