blob: 08730b9612b977ce8128ffc78bdec6629811f023 [file] [log] [blame]
Brian Waldon6c9f2ec2011-11-02 11:40:51 -04001import datetime
2
3
4#TODO(bcwaldon): expand this to support more iso-compliant formats
5ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
6
7
8def load_isotime(time_str):
9 """Convert formatted time stjring to a datetime object."""
10 return datetime.datetime.strptime(time_str, ISO_TIME_FORMAT)
11
12
13def dump_isotime(datetime_obj):
14 """Format a datetime object as an iso-8601 string."""
15 return datetime_obj.strftime(ISO_TIME_FORMAT)