From: Scott Worley Date: Fri, 3 Aug 2012 19:20:43 +0000 (-0700) Subject: Fix odd case of median X-Git-Url: http://git.scottworley.com/reliable-chat/commitdiff_plain/ac4bf273ffd4ff666af66d27b26ffef62d45c12c Fix odd case of median --- diff --git a/webclient/rc.html b/webclient/rc.html index 27dba59..e497135 100644 --- a/webclient/rc.html +++ b/webclient/rc.html @@ -173,10 +173,10 @@ times.push(message.ServerTimes[i]); } times.sort(); - var middle = times.length/2; if (times.length % 2) { - message.Time = times[middle]; + message.Time = times[(times.length-1)/2]; } else { + var middle = times.length/2; var difference = times[middle].getTime() - times[middle-1].getTime(); message.Time = new Date(times[middle-1].getTime() + difference/2); }