[olpc-nz] [OLPC-AU] Testing Summary: Auckland NZ - 19 March 2011

Tom Parker tom at carrott.org
Mon Mar 21 05:04:46 EDT 2011


On Mon, 2011-03-21 at 19:50 +1100, James Cameron wrote:
> On Mon, Mar 21, 2011 at 08:24:25PM +1300, Tabitha Roder wrote:
> > Power logs are attached. This release is in timezone "CST" which broke the
> > power log workflow as timezones seem to be very difficult in python. How do I
> > convert a string with a three letter timezone into seconds since the epoch? I
> > still haven't shared this script but the relevant code is:
> > 
> >     # WTF this doesn't parse 'Sat Mar 19 09:20:45 CST 2011'
> >     # laptopTZDate = datetime.strptime(dateString[6:-1], "%a %b %d %H:%M:%S %Z
> > %Y")
> >     # this only works for input in GMT
> >     laptopTZDate = time.strptime(dateString[6:-1], "%a %b %d %H:%M:%S %Z %Y")
> >     localTZDate = time.localtime(calendar.timegm(laptopTZDate))
> 
> The logging script needs a change that has already been applied to
> panelpwr-log [1], which records both the UNIX epoch timestamp (%s) and
> the "date -R" output, as a result the time would be better formatted for
> processing.

Recording the unix epoch timestamp sounds great! I'll look out for that
in future builds.

> In the meanwhile, set TZ to Australia/Darwin, strip the CST, and try
> strptime again.

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?





More information about the olpc-nz mailing list