Adding missing kong.common.utils module

Change-Id: I6015e6525205a1cfaaba2fc664cc1212afc2cb08
This commit is contained in:
Brian Waldon 2011-11-02 11:40:51 -04:00
parent 34ffa7e3d2
commit 6c9f2ec1de

15
kong/common/utils.py Normal file
View File

@ -0,0 +1,15 @@
import datetime
#TODO(bcwaldon): expand this to support more iso-compliant formats
ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
def load_isotime(time_str):
"""Convert formatted time stjring to a datetime object."""
return datetime.datetime.strptime(time_str, ISO_TIME_FORMAT)
def dump_isotime(datetime_obj):
"""Format a datetime object as an iso-8601 string."""
return datetime_obj.strftime(ISO_TIME_FORMAT)