def to_local_datetime(dt):
    """
    datetime.isoformat does not append +0000 when using UTC, javascript
    needs it, or the date is parsed as if it were in the local timezone
    """
    if not dt:
        return None
    ldt = dt.isoformat()
    return ldt if ldt[-6] == "+" else "%s+0000" % ldt