Discussion:
[Xmltv-devel] enabling use of guide data from different time zones without additional configuration in mythtv
Karl Dietz
2010-10-27 07:09:26 UTC
Permalink
Hi,

I propose to change the default for "TimeOffset" from "None" to "Auto"
or preferably even dropping the setting completely. Obviously this
comes a bit late for mythtv-0.24, no worries on that one.

I'm currently looking at a bug report of a user who wants to use the
guide from tv_grab_huro in the netherlands. The time zones are EET for
the guide and CET for the backend.

The default setting for "TimeOffset" in MythTV is "None" which lets
mythfilldatabase drop the explicit offset from the guide and interpret
it as local time in the backends time zone. Resulting in programs that
are off by the one hour that the time zones are different.

The setting "Auto" will honour the exlicit offset and add the local
offset. But it has a bug relating to programs around the DST change.
see http://svn.mythtv.org/trac/ticket/8217

As the XMLTV schema does not allow floating time there is no reason
for such guesswork making the "TimeOffset" setting unneccesary.
Let's ignore possible bugs in individual grabbers for now, especially
relating to the day of the DST switchover. But then, the stations get
them wrong more often then not, too. Especially when there's no useable
way to say "2:30 in the morning on october 31st" if that can be either
CET or CEST but you just don't know. (officialy that is 2a o'clock
CEST and 2b o'clock CET, but good luck using that in any program :)


Pseudocode for simplified datetime handling in fromXMLTVDate() matching
attached patch:
* take xmltv time and split it into time and time offset (same as now)
* create UTC timestamp (add explicit UTC, it's implicit localtime now)
* adjust for explicit offset (always, it's just for "Auto" now. if it's
not given that's implicit UTC, so no adjustment needed)
* convert to localtime (use Qt function instead of custom ones)


Con: Some guide sources are going to break, especially the ones that
emit floating localtime when the schema says it's implicit UTC
timestamps. (it's a violation of the guide schema and the guides I'm
aware of are of questionable quality anyway)

Pro: No more need to confuse users with crude hacks that break twice a
year or to tell them to mess with defaults when they want nothing
special. (see http://google.com/search?q=auto+xmltv+time+zone+mythtv )
On the other hand a new user can just setup tv_grab_combiner combining
guides from multiple time zones via mythtv-setup and it's just going to
work.
Target audience are all australian users, everyone who moved across a
time zone border and wants to what tv from home, any europeans wanting
to watch e.g. BBC (it's in another zone for most of us).

Regards,
Karl
Ben Bucksch
2010-10-27 09:14:44 UTC
Permalink
Post by Karl Dietz
Con: Some guide sources are going to break
FYI, I tried hard to get it right in my grabber, but it's close to
impossible. I can't just take the grabbing machine's local time offset
or date offset, because that may be in a different timezone and then I
could just as well not use any timezone. I can't use the source's
timezone, because it doesn't provide one.
Karl Dietz
2010-10-27 17:53:13 UTC
Permalink
Hi Ben,
Post by Ben Bucksch
Post by Karl Dietz
Con: Some guide sources are going to break
FYI, I tried hard to get it right in my grabber, but it's close to
impossible. I can't just take the grabbing machine's local time offset
or date offset, because that may be in a different timezone and then I
could just as well not use any timezone. I can't use the source's
timezone, because it doesn't provide one.
Well, you do know the time zone the datasource is aligned to even if
it's not provided as explicit dataset. E.g. a german source with
floating (undefined) time will usually be delivering timestamps in
Europe/Berlin. If you have a source that delivers time in UTC you, the
writer of the grabber, will know that and can use your knowledge to
make the output of your grabber be explicit about the timestamps.

Regards,
Karl
Ben Bucksch
2010-10-27 19:15:14 UTC
Permalink
Post by Karl Dietz
Well, you do know the time zone the datasource is aligned to even if
it's not provided as explicit dataset. E.g. a german source with
floating (undefined) time will usually be delivering timestamps in
Europe/Berlin.
Correct. I also know the date and time from the data.
However, knowing when exactly the summer/winter time transition is is a
non-trivial problem. You basically need Linux tzdata for that (which
changes every few weeks), and very few language APIs implement this
properly. My converter is written in XSLT, and I don't think it has such
functions. If you know such functions for python and perl, please
mention them here for the benefit of the other grabber writers.
Karl Dietz
2010-10-27 19:41:18 UTC
Permalink
Post by Ben Bucksch
Post by Karl Dietz
Well, you do know the time zone the datasource is aligned to even if
it's not provided as explicit dataset. E.g. a german source with
floating (undefined) time will usually be delivering timestamps in
Europe/Berlin.
Correct. I also know the date and time from the data.
However, knowing when exactly the summer/winter time transition is is a
non-trivial problem. You basically need Linux tzdata for that (which
changes every few weeks), and very few language APIs implement this
properly. My converter is written in XSLT, and I don't think it has such
functions. If you know such functions for python and perl, please
mention them here for the benefit of the other grabber writers.
I'm using the DateTime modules from CPAN as some other grabbers. It has
it's own time zone collection based on
http://en.wikipedia.org/wiki/Tz_database

Google suggests http://pypi.python.org/pypi/pytz/ for Python.

For XML/XSLT I have not yet seen anything that handles the tz database.

Regards,
Karl

Loading...