|
[root@intruder bin]# diff -Nur tv_grab_au_reg tv_grab_au_reg.timezone-patched --- tv_grab_au_reg 2006-09-08 23:08:51.000000000 +1000 +++ tv_grab_au_reg.timezone-patched 2006-09-08 23:24:28.000000000 +1000 @@ -309,9 +309,9 @@ channelTimezone = channel['channeltz'] subStr = r'\1 ' + channelTimezone startTime = node.getAttribute('start') - node.setAttribute('start', timeRE.sub(subStr, startTime)) + node.setAttribute('start', timeRE.sub(subStr, applyTimezone(startTime, channelTimezone))) endTime = node.getAttribute('stop') - node.setAttribute('stop', timeRE.sub(subStr, endTime)) + node.setAttribute('stop', timeRE.sub(subStr, applyTimezone(endTime, channelTimezone))) elif force_explicit_timezone: startTime = node.getAttribute('start') match = timeRE.search(startTime) @@ -330,6 +330,20 @@ print out print "\n" + +def applyTimezone(time, tz): + p = re.compile(r'(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)') + m = [ int(x) for x in p.match(time).groups() ] + date = datetime.datetime(*m) + + p = re.compile(r'(\W\d\d)(\d\d)') + m = [ int(x) for x in p.match(tz).groups() ] + timezone = datetime.timedelta(hours=m[0], minutes=m[1]) + + date = date + timezone + return date.strftime("%Y%m%d%H%M%S") + + def outputData(conversionMap, filt, f): global verbose, output, force_explicit_timezone Attachment:
tv_grab_au_reg |