From 454c7ae8b7d4c683ef19df46d83a35a1f18b48fd Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 29 Oct 2016 12:12:26 +0200 Subject: todo: Better date reporting --- modules/todo/todo.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'modules/todo/todo.html') diff --git a/modules/todo/todo.html b/modules/todo/todo.html index 309fb18..b196682 100644 --- a/modules/todo/todo.html +++ b/modules/todo/todo.html @@ -41,13 +41,20 @@ function pad(s,n,c){ } function beginOfDay(date){ - return new Date(date.getTime()-date.getHours()*3600*1000-date.getMinutes()*60*1000-date.getSeconds()*1000-date.getMilliseconds()); + var d=new Date(date.getTime()); + d.setHours(0); + d.setMinutes(0); + d.setSeconds(0); + d.setMilliseconds(0); + return d; } function fancytime(timeS){ return pad(timeS.hour,2,"0")+":"+pad(timeS.min,2,"0")+(timeS.sec==0?"":":"+pad(timeS.sec,2,"0")); } +var weekdays=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]; + function fancydate(date){ var now=new Date(); var nowS=datesplit(new Date()); @@ -62,12 +69,12 @@ function fancydate(date){ } var diffweeks=~~(diffdays/7); if(diffweeks>0){ - return "In "+diffweeks+" week"+(diffweeks==1?"":"s")+", "+diffdays%7+" day"+(diffdays%7==1?"":"s"); + return weekdays[(date.getDay()+6)%7]+" in "+diffweeks+" week"+(diffweeks==1?"":"s"); } if(diffdays==1){ return "Tomorrow, "+fancytime(dateS); } - return "In "+diffdays+" day"+(diffdays==1?"":"s")+", "+fancytime(dateS); + return weekdays[(date.getDay()+6)%7]+", "+fancytime(dateS); } function tablerowfor(task){ @@ -210,7 +217,6 @@ body{ font-size:12px; font-style:italic; display:inline-block; - cursor:help; } .subdate{ color:#ccc; -- cgit v1.2.3-54-g00ecf