to_xml: fix date handling