Fixed date handling in Javascript