def parse_date_time(d, t, network):
 if (not network_dict):
  load_network_dict()
 parsed_time = time_regex.search(t)
 network_tz = get_network_timezone(network)
 hr = 0
 m = 0
 if parsed_time:
  hr = try_int(parsed_time.group('hour'))
  m = try_int(parsed_time.group('minute'))
  ap = parsed_time.group('meridiem')
  ap = (ap[0].lower() if ap else '')
  if ((ap == 'a') and (hr == 12)):
   hr -= 12
  elif ((ap == 'p') and (hr != 12)):
   hr += 12
  hr = (hr if (0 <= hr <= 23) else 0)
  m = (m if (0 <= m <= 59) else 0)
 result = datetime.datetime.fromordinal(max(try_int(d), 1))
 return result.replace(hour=hr, minute=m, tzinfo=network_tz)

def parse_date_time ( d , t , network ) : if ( not network_dict ) : load_network_dict ( ) parsed_time = time_regex . search ( t ) network_tz = get_network_timezone ( network ) hr = 0 m = 0 if parsed_time : hr = try_int ( parsed_time . group ( 'hour' ) ) m = try_int ( parsed_time . group ( 'minute' ) ) ap = parsed_time . group ( 'meridiem' ) ap = ( ap [ 0 ] . lower ( ) if ap else '' ) if ( ( ap == 'a' ) and ( hr == 12 ) ) : hr -= 12 elif ( ( ap == 'p' ) and ( hr != 12 ) ) : hr += 12 hr = ( hr if ( 0 <= hr <= 23 ) else 0 ) m = ( m if ( 0 <= m <= 59 ) else 0 ) result = datetime . datetime . fromordinal ( max ( try_int ( d ) , 1 ) ) return result . replace ( hour = hr , minute = m , tzinfo = network_tz )
parse date and time string into local time .