fix bug crash when datetime is nil