[mythtv-users] Daylight savings clock changes (was for Aussies [and a bit OT])

Cougar mythtv at lost.data.ee
Mon Oct 31 17:05:43 EST 2005


Btw, here is hack I'm using for tv_grab_ee server side (we get XMLTV 
already from server). In database, all times are local times, so what I 
did is that I checked all times against daylight-saving time at this 
particular moment and modified timestamp accordingly to get GMT time with 
right timezone offset. It can be done smarter way possibly. But 
it works and the most important thing is to get right times and that I got 
;-)

In main code I have

my $startstr = &date_to_tz($ref->{'fromDate'}, $ref->{'fromTime'}, $isnextday);
my $stopstr = &date_to_tz($ref->{'toDate'}, $ref->{'toTime'}, $isnextday);

$isnextday is 1 if there are shows in this day's schedule but they are 
after midnight, ie at next day actually.

And function itself is

sub date_to_tz()
{
	my ($datestr, $timestr, $isnextday) = @_;

	my ($xyear, $xmon, $xmday, $xhour, $xmin, $xsec) = split (/[ :\.\-]/, $datestr . " " . $timestr);

	my $is24 = 0;
	$is24 = 1 if ($xhour == 24);
	$xhour-- if ($is24);    # back one hour
	my $time = timelocal($xsec, $xmin, $xhour, $xmday, $xmon - 1, $xyear);
	$time += 3600 if ($is24);

	$time += 86400 if ($isnextday);

	my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
	my $tz = sprintf("%02d00", 2 + $isdst);
	$tz = "+$tz" if ($tz >= 0);
	return sprintf("%04d%02d%02d%02d%02d%02d %s", $year + 1900, $mon + 1, $mday, $hour, $min, $sec, $tz);
}

If you use something like this in grabber and set "Time offset for XMLTV 
listings" to "Auto" in mythtv-setup then you don't have dst problem any 
more as long you server knows your timezone.

Btw, my timezone is EET (+2) and summer time is EEST (+3). You should change
this (2 + $isdst) if you have any other timezone.

Hope it helps if anyone has any plans to implement such feature in your
grabber.

-- 
Cougar

On Tue, 1 Nov 2005, Phill Edwards wrote:

> Did any others of you forget to update your config file for tv_grab_au
> and then get all the programme times out by 1 hour? I did and I'm in a
> lot of trouble with WAF now - if anyone has lasy night's recording of
> SuperNanny would I please be able to get a copy of it somehow?
> 
> In future I guess I could safeguard against my negligence by running a
> script when the clocks change to update the config file, but I don't
> know how to detect that DST has kicked in or off. Does anyone know how
> to do that? And if they do, how would you test it short of updating
> the date in the BIOS?
> 
> Regards,
> Phill


More information about the mythtv-users mailing list