Fix date parsing in JS