from datetime import datetime
import time


def http_date_from_timestamp(timestamp):
    """
    Turn a modifier or created tiddler timestamp
    into a proper formatted HTTP date.
    """
    try:
        try:
            timestamp_datetime = datetime(*(time.strptime(timestamp,
                '%Y%m%d%H%M')[0:6]))
        except ValueError:
            timestamp_datetime = datetime(*(time.strptime(timestamp,
                '%Y%m%d%H%M%S')[0:6]))
    except ValueError:
        timestamp_datetime = datetime.utcnow()
    return timestamp_datetime.strftime('%a, %d %b %Y %H:%M:%S GMT')