Ran across an interesting JavaScript

Ran across an interesting JavaScript anomaly at work today. We have instances where we want to limit the number of days worth of data that our customers can select for inclusion in a report. It’s a function of resource loading. To implement these controls, I wrote a JavaScript function, which just looked at the selected start and end dates and figured out what the difference was in days. If the delta was to big, the user received a message and was given the opportunity to change the date range. Nothing really fancy just used the date and time methods in JavaScript. The anomaly occurred when I tested its functionality. For the same input dates the function calculated different delta days when run on IE under Win2000 and Netscape 7.0 on Mac OS X 10.1. The difference was one day. Who would of thought that these implementations of JavaScript would do that? Wonder where else this is a problem and how it is impacting our other code.

Leave a comment