def formatdate(now=None, usegmt=False) ->str:
    """
    format time as UTC
    """
    import time
    import datetime
    if not now:
        now = time.time()
    if usegmt:
        dt = datetime.datetime.fromtimestamp(now, datetime.timezone.utc)
    else:
        dt = datetime.datetime.utcfromtimestamp(now)
    zone = '-0000'
    months = {(1): 'Jan', (2): 'Feb', (3): 'Mar', (4): 'Apr', (5): 'May', (
        6): 'Jun', (7): 'Jul', (8): 'Aug', (9): 'Sep', (10): 'Oct', (11):
        'Nov', (12): 'Dec'}
    weeks = {(0): 'Mon', (1): 'Tue', (2): 'Wed', (3): 'Thu', (4): 'Fri', (5
        ): 'Sat', (6): 'Sun'}
    return '{week}, {d} {m} {y} {h}:{M}:{s:02} {zone}'.format(week=weeks.
        get(dt.weekday()), d=dt.day, m=months.get(dt.month), y=dt.year, h=
        dt.hour, M=dt.minute, s=dt.second, zone=zone)
