Fix date processing with JavaScript