formats dates correctly