[mythtv] XMLTV timestamps, TimeOffset and mythfilldatabase
William Uther
willu.mailingLists at cse.unsw.edu.au
Mon Apr 11 13:24:30 UTC 2005
Hi all,
Firstly, this is a non-urgent email. If you're working hard on 0.18,
put this aside until later :).
I'm writing a new XMLTV grabber for Australia (
http://www.cse.unsw.edu.au/~willu/xmltv/ ). In the process I came
across some strangeness in the way Myth handles the time information in
XMLTV data. I propose to clean it up, but don't want to tread on any
toes.
Here is the way things currently work:
In the XMLTV spec, a timestamp without a timezone spec is defined to be
UTC. In mythtv-setup you can set a TimeOffset to "None", "Auto", or
another time offset. This gets used in mythfilldatabase.
It is in mythfilldatabase that things get a little convoluted:
- If "Auto" time offset is selected, then this is calculated _once_
based on current time when mythfilldatabse starts running. (in
parseFile())
- Then, for each program:
- The start and end time have the timezone offset added to their
text (parseProgram() calls addTimeOffset()). To achieve this:
- If the TimeOffset setting is not "None" then:
- addTimeOffset() parses the text representation into a
QDateTime var
- If there is no timezone spec on the timestamp then
addTimeOffset() assumes that the timezone is equal to the TimeOffset
setting. This will cause the two to cancel, leaving the time treated
as local time, and rendering the TimeOffset setting useless.
- addTimeOffset() then adds the timezone spec and the
timeoffset to the original timestamp and re-writes the textual
timestamp in this 'local time'.
- Finally, the start and end time texts are reparsed by a second
time parser (parseProgram() calls fromXMLTVDate())
- fromXMLTVDate() ignores any timezone spec.
This seems strange for a number of reasons:
- If there is no timezone spec then the result is to read the
timestamp as localtime, not UTC as in the XMLTV spec.
- If there is no timezone spec then the TimeOffset value is ignored
entirely.
- Otherwise, if the TimeOffset is set to "None" then any timezone
spec in the timestamp is ignored, but left in the text field. In other
cases the timezone spec is honoured, but stripped from the text.
- If the TimeOffset is set to "Auto" then the same offset is used for
all programs, even if the timezone changes in the middle of a grab
(think about the week overlapping the start or end of daylight time).
- The timestamp is parsed, converted back into text, and parsed
again... using two different parsers.
I think we need these features:
- A mechanism to ignore timezone offsets and just treat things as
localtime: "None" TimeOffset setting
- Timestamps follow the xmltv spec (i.e. missing timezone spec = UTC)
- "Auto" TimeOffset setting should base the time offset on the time
the program is showing, not the time mythfilldatabase is run
- The timestamps should be parsed once by one piece of code
- I'm not sure if the internal textual representation should have a
timezone spec. If it doesn't, then the internal textual representation
is different to the xmltv representation (but that is not a big deal).
If it does, then it does... I'm not sure where these are used anyway.
I propose to (In my spare time, some time):
- Combine the addTimeOffset() and fromXMLTVDate() functions so we
have one parser
- Change the meaning of a missing timezone spec to mean UTC instead
of local time (in line with the XMLTV spec). Setting the TimeOffset
value to "None" will allow people to achieve the old effect - the
timestamp interpreted as local time.
- Make "Auto" TimeOffset do the conversion to local time for each
program.
Any thoughts, comments?
Will :-}
--
Dr William Uther National ICT Australia
Phone: +61 2 9385 6357 Computer Science and Engineering
Email: willu at cse.unsw.edu.au University of New South Wales
Web: http://www.cse.unsw.edu.au/~willu/ Sydney, Australia
More information about the mythtv-dev
mailing list