Fix a few datetime bugs