'Attempt to convert to utc-iso time string using datetime methods.'

@staticmethod
def encode_as_datetime(obj):

    try:
        obj = obj.astimezone(pytz.utc)
    except ValueError:
        pass
    except TypeError:
        pass
    except AttributeError:
        raise NotEncodable
    try:
        time_string = obj.isoformat()
    except AttributeError:
        raise NotEncodable
    else:
        return iso_to_plotly_time_string(time_string)
