From 430197458cf31f9d069573fb541ca0c3e8d1d7fc Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 7 Feb 2022 12:17:35 +0100 Subject: timetrack: Mark today in calendar --- modules/timetrack/timetrack.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/timetrack/timetrack.html b/modules/timetrack/timetrack.html index 8d89455..6643d05 100644 --- a/modules/timetrack/timetrack.html +++ b/modules/timetrack/timetrack.html @@ -129,8 +129,12 @@ function refreshlist(list){ } } +function daystart(date){ + return new Date(date.getFullYear(), date.getMonth(), date.getDate()); +} + function weekstart(date){ - var d=new Date(date.getFullYear(), date.getMonth(), date.getDate()); + var d=daystart(date); var wkday=(d.getDay()+6)%7; return new Date(d - wkday*24*3600*1000); } @@ -191,7 +195,8 @@ function refreshcalendar(list,npreweeks){ tr.appendChild(td); tb.appendChild(tr); - var thismonday=weekstart(new Date()); + var now=new Date(); + var today=daystart(now), thismonday=weekstart(now); for(var wkoff=-npreweeks;wkoff<=1;wkoff++){ var monday=new Date(thismonday.getTime() + wkoff*7*24*3600*1000); @@ -215,6 +220,7 @@ function refreshcalendar(list,npreweeks){ td=document.createElement("td"); td.appendChild(document.createTextNode(descr)); td.setAttribute("style","background-color:rgb("+(255-255*surplus)+","+(255-255*(deficit+surplus))+","+(255-255*deficit)+")"); + if(day.getTime()==today.getTime())td.classList.add("today"); tr.appendChild(td); } tb.appendChild(tr); @@ -392,6 +398,10 @@ body{ text-align:right; width:50px; } +#calendartb td.today{ + border:1px black solid; + font-weight:bold; +} -- cgit v1.2.3-70-g09d2