Mailing List Archive

MySQL 5.7 / DATETIME / Python Bindings: timezone problem (2)
Installed a new Ubuntu 18.04 server, using unchanged Mythtv 29.0-fixes.

mysql-server, 5.7.25-0ubuntu0.18.04.2



I am using lossless_cut with the Python bindings and noticed the following
problem:



/usr/local/lib/python2.7/dist-packages/MythTV/_conn_mysqldb.py:72: Warning:
(1292L, u"Incorrect datetime value: '2016-12-27 18:50:00+01:00' for column
'starttime' at row 1")



Datetime only have a fraction, not a timezone. This seems to generate
warnings with newer mysql.



Setting TZ=UTC, a timezone part is still added to the query, changed the
warning in

/usr/local/lib/python2.7/dist-packages/MythTV/_conn_mysqldb.py:72: Warning:
(1292L, u"Incorrect datetime value: '2016-12-27 17:50:00+00:00' for column
'starttime' at row 1")



default-time-zone = 'UTC', in the mysqld configuration produced the same
warning.



Added some debugging which shows that a TZ is set on the recorded.starttime
variable and used to setup following queries.

('starttime', datetime(2016, 12, 27, 18, 50,
tzinfo=<MythTV.utility.dt.offsettzinfo object at 0x7fec00d65c90>))

('query:', u"SELECT genre FROM `programgenres` WHERE chanid=10262 AND
starttime='2016-12-27 18:50:00+01:00' LIMIT 1;")





Although a warning, only results are delivered when TZ=UTC is used (the TZ
is still somehow stripped); matching the Mythtv datetimes in UTC.



Would it not be better the backend API sends datatimes without TZ (also in
the bindings)? Leaving localization to the client.

Other ideas to fix this kind of problem?



Cheers

Angela