Added to-date-time code-rewriting function