from datetime import datetime


def json_datetime_handler(x):
    """ Format datetime objects for the json engine """
    if isinstance(x, datetime):
        return x.isoformat()
    raise TypeError("Unknown type")