def str2time(s):
 suffixes = (('S', 1), ('M', 60), ('H', (60 * 60)), ('D', ((60 * 60) * 24)), ('W', (((60 * 60) * 24) * 7)), ('Y', (((60 * 60) * 24) * 365)))
 if (_PY3 and isinstance(s, bytes)):
  s = s.decode('ascii')
 if isinstance(s, str):
  s = s.upper().strip()
  for (suff, mult) in suffixes:
   if s.endswith(suff):
    return int((float(s[:(-1)]) * mult))
  try:
   s = int(s)
  except ValueError:
   raise ValueError(('Invalid time interval specifier: ' + s))
 return s

def str2time ( s ) : suffixes = ( ( 'S' , 1 ) , ( 'M' , 60 ) , ( 'H' , ( 60 * 60 ) ) , ( 'D' , ( ( 60 * 60 ) * 24 ) ) , ( 'W' , ( ( ( 60 * 60 ) * 24 ) * 7 ) ) , ( 'Y' , ( ( ( 60 * 60 ) * 24 ) * 365 ) ) ) if ( _PY3 and isinstance ( s , bytes ) ) : s = s . decode ( 'ascii' ) if isinstance ( s , str ) : s = s . upper ( ) . strip ( ) for ( suff , mult ) in suffixes : if s . endswith ( suff ) : return int ( ( float ( s [ : ( - 1 ) ] ) * mult ) ) try : s = int ( s ) except ValueError : raise ValueError ( ( 'Invalid time interval specifier: ' + s ) ) return s
parse a string description of an interval into an integer number of seconds .