From f7b7c710e7b643bf836616d1890b4df0701d7bbe Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 31 Jul 2011 18:51:13 +0200 Subject: [PATCH] interval dependend time format for headline --- htdocs/frontend/javascripts/wui.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/frontend/javascripts/wui.js b/htdocs/frontend/javascripts/wui.js index 35abb8a..f712afd 100644 --- a/htdocs/frontend/javascripts/wui.js +++ b/htdocs/frontend/javascripts/wui.js @@ -434,8 +434,14 @@ vz.wui.formatNumber = function(number, prefix) { } vz.wui.updateHeadline = function() { - var from = $.plot.formatDate(new Date(vz.options.plot.xaxis.min), '%d. %b %y %h:%M', vz.options.plot.xaxis.monthNames, true); - var to = $.plot.formatDate(new Date(vz.options.plot.xaxis.max), '%d. %b %y %h:%M', vz.options.plot.xaxis.monthNames, true); + var delta = vz.options.plot.xaxis.max - vz.options.plot.xaxis.min; + var format = '%d. %b %y'; + + if (delta < 3*24*3600*1000) format += ' %h:%M'; // under 3 days + if (delta < 5*60*1000) format += ':%S'; // under 5 minutes + + var from = $.plot.formatDate(new Date(vz.options.plot.xaxis.min), format, vz.options.plot.xaxis.monthNames, true); + var to = $.plot.formatDate(new Date(vz.options.plot.xaxis.max), format, vz.options.plot.xaxis.monthNames, true); $('#title').html(from + ' - ' + to); }