15.9.1.14 TimeClip(time)

2010-07-19

long TimeClip(time:int|number)

Convert time to a timestamp in milliseconds. Returns NaN if time is infinite or out of bounds (100 years either side).

Code: (Meta Ecma)
TimeClip = function(time){
if (!IsFinite(time)) return NaN;
if (Math.abs(time) > 8.64 * Math.pow(10,15)) return NaN;
return ToInteger(time);
// an implementation may add +0 to convert a -0 to +0 if that internally matters
}

The last step is to allow an implementation to choose whether it wants to distinguish -0 from +0 internally.