On Mon, Mar 21, 2011 at 10:04:46PM +1300, Tom Parker wrote: > Uggh. More about what I'm trying to do. After collecting the power logs > from each XO, I want to work out which correspond to "today". This is > surprisingly difficult when the XOs have some semi-random time zone and > our testing sessions often span a day boundary in the GMT time zone. So > I wrote a script to rename the log files to my local time. I > (foolishly ??) chose to do this in python. I'm running on my laptop, not > the XO and it's beginning to sound like I should give up and use java > where SimpleDateFormat would be my friend. > > I could maybe make a mapping between the three letter timezone and the > longer timezone name and work out how to change timezones within the > script before parsing, but surely there has to be a better way?
The problem is much simpler ... by being impossible ... the timezone is _missing_ from the log, and you can't reliably reconstruct it, especially since you are also testing builds that have a timezone set already. The timezone abbreviation that is present isn't unique. You _can_ reliably reconstruct the UTC offset of the timezone, which might be enough for your purposes. Take the first log line after <StartData>, and use this as the date of the file. You might then take a punt and relate this to the DATE line, or take into account rhe BUILD: line. ;-) However, you will need to assume the XO's RTC or hardware clock $(hwclock) is set properly. In OpenFirmware I use "wifi networkname" followed by "ntp-set-clock". In Linux, I use "ntpdate pool.ntp.org && hwclock --systohc --utc". Do it first in Linux to see the total drift so far. In current builds the RTC may drift backward, see #10757. Looking at file pwr-CSN74804D7E-110319_092045.csv we see the first data line is: 1300492245,52,6379990,-1155598,3053,6583214,Discharging,startup ... and this is ... $ TZ=Australia/Darwin date --date=@1300492245 Sat Mar 19 09:20:45 CST 2011 ... which matches the DATE: line ... DATE: Sat Mar 19 09:20:45 CST 2011 -- James Cameron http://quozl.linux.org.au/ _______________________________________________ Testing mailing list [email protected] http://lists.laptop.org/listinfo/testing
