import time
import calendar


def parseTimestampZulu(s, allowDateOnly=False):
    """
  Parses a time (or just a date, if 'allowDateOnly' is true) in ISO
  8601 UTC format and returns a Unix timestamp.  Raises an exception
  on parse error.
  """
    t = None
    if allowDateOnly:
        try:
            t = time.strptime(s, "%Y-%m-%d")
        except:
            pass
    if t == None:
        t = time.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
    return calendar.timegm(t)