def iso_utc_time_to_seconds(isotime, _conversion_re=re.compile('(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})[T_ ](?P<hour>\\d{2}):(?P<minute>\\d{2}):(?P<second>\\d{2})(?P<subsecond>\\.\\d+)?Z?')):
 m = _conversion_re.match(isotime)
 if (not m):
  raise ValueError, (isotime, 'not a complete ISO8601 timestamp')
 (year, month, day) = (int(m.group('year')), int(m.group('month')), int(m.group('day')))
 (hour, minute, second) = (int(m.group('hour')), int(m.group('minute')), int(m.group('second')))
 subsecstr = m.group('subsecond')
 if subsecstr:
  subsecfloat = float(subsecstr)
 else:
  subsecfloat = 0
 return (calendar.timegm((year, month, day, hour, minute, second, 0, 1, 0)) + subsecfloat)

def iso_utc_time_to_seconds ( isotime , _conversion_re = re . compile ( '(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})[T_ ](?P<hour>\\d{2}):(?P<minute>\\d{2}):(?P<second>\\d{2})(?P<subsecond>\\.\\d+)?Z?' ) ) : m = _conversion_re . match ( isotime ) if ( not m ) : raise ValueError , ( isotime , 'not a complete ISO8601 timestamp' ) ( year , month , day ) = ( int ( m . group ( 'year' ) ) , int ( m . group ( 'month' ) ) , int ( m . group ( 'day' ) ) ) ( hour , minute , second ) = ( int ( m . group ( 'hour' ) ) , int ( m . group ( 'minute' ) ) , int ( m . group ( 'second' ) ) ) subsecstr = m . group ( 'subsecond' ) if subsecstr : subsecfloat = float ( subsecstr ) else : subsecfloat = 0 return ( calendar . timegm ( ( year , month , day , hour , minute , second , 0 , 1 , 0 ) ) + subsecfloat )
the inverse of iso_utc() .