15.9.1.2 Day number and time within day

2010-07-12

These are algorithms to determine the day from the epoch or the time within the day of the timestamp.

Note that this is the way to Ecmascript determines the day, regardless of actual calendar oddities (leap seconds, etc).

Code: (Meta Ecma)
function Day(t){
var msPerDay = 86400000;
return Math.floor(t/msPerDay);
}
function timeInDay(t){
var msPerDay = 86400000;
return Math.floor(t % msPerDay);
}