Fix date encoding