def parse_iso8601(date_str, delimiter=u'T', timezone=None):
 if (date_str is None):
  return None
 date_str = re.sub(u'\\.[0-9]+', u'', date_str)
 if (timezone is None):
  (timezone, date_str) = extract_timezone(date_str)
 try:
  date_format = u'%Y-%m-%d{0}%H:%M:%S'.format(delimiter)
  dt = (datetime.datetime.strptime(date_str, date_format) - timezone)
  return calendar.timegm(dt.timetuple())
 except ValueError:
  pass

def parse_iso8601 ( date_str , delimiter = u'T' , timezone = None ) : if ( date_str is None ) : return None date_str = re . sub ( u'\\.[0-9]+' , u'' , date_str ) if ( timezone is None ) : ( timezone , date_str ) = extract_timezone ( date_str ) try : date_format = u'%Y-%m-%d{0}%H:%M:%S' . format ( delimiter ) dt = ( datetime . datetime . strptime ( date_str , date_format ) - timezone ) return calendar . timegm ( dt . timetuple ( ) ) except ValueError : pass
return a unix timestamp from the given date .