diff options
Diffstat (limited to 'modules/timetrack2/timetrack.html')
-rw-r--r-- | modules/timetrack2/timetrack.html | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/timetrack2/timetrack.html b/modules/timetrack2/timetrack.html index 209458d..1925a26 100644 --- a/modules/timetrack2/timetrack.html +++ b/modules/timetrack2/timetrack.html @@ -54,10 +54,14 @@ function daystart(date){ return new Date(date.getFullYear(), date.getMonth(), date.getDate()); } +function shiftdays(date, off) { + var d = new Date(date); + d.setDate(d.getDate() + off); + return d; +} + function weekstart(date){ - var d=daystart(date); - var wkday=(d.getDay()+6)%7; - return new Date(d - wkday*24*3600*1000); + return shiftdays(daystart(date), -(date.getDay() + 6) % 7); } var monthnames=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; @@ -199,7 +203,7 @@ function refreshcalendar(list,npreweeks){ 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); + var monday = shiftdays(thismonday, wkoff * 7); tr = document.createElement("tr"); td = document.createElement("td"); @@ -211,7 +215,7 @@ function refreshcalendar(list,npreweeks){ tr.appendChild(td); for (var i = 0; i < 7; i++) { - var day = new Date(thismonday.getTime() + (wkoff*7+i)*24*3600*1000); + var day = shiftdays(thismonday, wkoff * 7 + i); var tm = hist.get(datekey(day)) || 0; var descr = Math.round(tm/1000/3600*10)/10 + "h"; var target = (day.getDay()+6)%7 < 5 ? 38/5 - 1 : 0; |