Javascript date calculation

A little contribution to make the Genetics Department fly facility media ordering system more user friendly. This snippet calculates the earliest possible delivery date to be used as default delivery time. The challenge was of course writing it without a single comparison or [if] clause. It ran for a while until Sysadmin Ian decided that he wanted one with more functionality.

var asap = new Date(new Date().getTime()+129600000);
asap.setTime(asap.getTime()+86400000*((asap.getDay()+1)%5)*(Math.exp(0, (asap.getDay()%6))));

(Tomorrow, if it is before 12 o’clock, otherwise the day after tomorrow, but either only if that day is not a day of the weekend. In that case the Monday after.)

Leave a Reply

Your email address will not be published.


Please simplify: \(\cos (150\pi)=\)