diff options
author | Tom Smeding <tom@tomsmeding.com> | 2022-02-07 12:17:35 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2022-02-07 12:17:35 +0100 |
commit | 430197458cf31f9d069573fb541ca0c3e8d1d7fc (patch) | |
tree | 7e17d8328527a97c597c6fa953e40dbf7e0587ed /modules/timetrack | |
parent | 5c3de9e0a3de5844ac5104d909d6a33c89238d30 (diff) |
timetrack: Mark today in calendar
Diffstat (limited to 'modules/timetrack')
-rw-r--r-- | modules/timetrack/timetrack.html | 14 |
1 files 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; +} </style> </head> <body> |