CRLSCSClub / CRLSTime

A clock for showing the CRLS schedule during the school day
6 stars 10 forks source link

Allow date override #49

Open psvenk opened 5 years ago

psvenk commented 5 years ago

This PR closes #46.

The variable now is now declared as a global variable at the beginning of draw.js and is assigned in drawClock(), based on the current ServerDate and a new global variable offset (in milliseconds). A new function has been added, devOverrideDate(date) with type signature Date | Number | String -> void, which constructs a Date object from the parameter and sets offset such that now is set to this Date object and counts onward. Additionally, all references to today have been replaced by references to now, as I see no need to maintain a separate variable for the client-side time. getStart() has been changed to construct a new Date object instead of using the mutable Date.prototype.setHours().