[mythtv-users] Changing time from UTC to Local [answer]

Kevin Hjelden mythtv at burntpopcorn.net
Thu Apr 8 18:07:28 EDT 2004


I'm sending this to the list so that anyone else who sees this might
find it useful, and for the archives (there wasn't really anything about
my specific problem in it)

I've had problems with getting my time zone set up in gentoo for a
while. Recently I finally figured out how to get the time zone set up
correctly. The short answer is that I didn't realize to look in the US
directory for Pacific and instead just put /usr/share/zoneinfo/Pacific
as the symlink from /etc/localtime, which doesn't work. To work around
this issue, I had my machine set to the local time, but in the time zone
of UTC, so if it was 2pm pacific, I had my computer set to 14:00 UTC to
get the recordings to work at the same time. However, daylight savings
time kinda kicked me in the butt on that one, so alas it's fixed.
However, all the recordings are saved with UTC as the filename (maybe
only in cvs.. i just checked out cvs before I did this). With help from
Donour on #mythtv-users, this script came out of it to rename all the
filenames back 8 hours so that it would work now. So, here is the script.

Kevin

---filename: rollback.py----CUT HERE----
# Author Donour Sizemore : Released to Public Domain
# Usage: python rollback.py *.nuv
import sys
from datetime import datetime,timedelta

rollback = timedelta(hours = 8)

for file in sys.argv[1:]:
     ext   = file[-4:]
     channel=file[:4]

     syear = int(file[5:9])
     smonth= int(file[9:11])
     sday  = int(file[11:13])
     shour = int(file[13:15])
     smin  = int(file[15:17])
     ssec  = int(file[17:19])

     eyear = int(file[20:24])
     emonth= int(file[24:26])
     eday  = int(file[26:28])
     ehour = int(file[28:30])
     emin  = int(file[30:32])
     esec  = int(file[32:34])

     start = datetime(syear,smonth,sday,shour,smin,ssec) - rollback
     end   = datetime(eyear,emonth,eday,ehour,emin,esec) - rollback

     newfile = "%s_%s%.2d%.2d%.2d%.2d%.2d_%s%.2d%.2d%.2d%.2d%.2d%s" % \
	(channel,start.year,start.month,start.day,start.hour,start.minute,start.second, 

\
      end.year,end.month,end.day,end.hour,end.minute,end.second,ext)

     print "mv -f ", file, newfile



More information about the mythtv-users mailing list