Updated handling of dates in templates.