from datetime import datetime


def parse_timestamp(timestamp):
    """
    parse_timestamp parses a timestamp and returns a datetime.
    """
    # python 3.6 doesn't support colons in timestamps, but Pixiv's API
    # returns timestamps with colons.
    if ":" == timestamp[-3:-2]:
        timestamp = timestamp[:-3] + timestamp[-2:]

    return datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S%z")