Permalink
Browse files

Update additional tables for UTC.

  • Loading branch information...
daniel-kristjansson committed Jun 6, 2012
1 parent 36364d1 commit 92bf53d52d37d881055ac752a45caf3af13e9959
@@ -5,7 +5,7 @@
"""
OWN_VERSION = (0,26,-1,1)
SCHEMA_VERSION = 1303
SCHEMA_VERSION = 1304
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
PROTO_VERSION = '75'
@@ -57,7 +57,7 @@
* mythtv/bindings/php/MythBackend.php
#endif
#define MYTH_DATABASE_VERSION "1303"
#define MYTH_DATABASE_VERSION "1304"
MBASE_PUBLIC const char *GetMythSourceVersion();
@@ -2118,6 +2118,61 @@ NULL
return false;
}
if (dbver == "1303")
{
QDateTime loc = QDateTime::currentDateTime();
QDateTime utc = loc.toUTC();
loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
int utc_offset = loc.secsTo(utc) / 60;
QList<QByteArray> updates_ba;
// Convert various DATETIME fields from local time to UTC
if (0 != utc_offset)
{
const char *with_endtime[] = {
"recordedprogram",
};
const char *without_endtime[] = {
"recordedseek", "recordedmarkup", "recordedrating",
"recordedcredits",
};
QString order = (utc_offset > 0) ? "-starttime" : "starttime";
for (uint i = 0; i < sizeof(with_endtime)/sizeof(char*); i++)
{
updates_ba.push_back(
QString("UPDATE %1 "
"SET starttime = starttime + interval %2 minute, "
" endtime = endtime + interval %3 minute "
"ORDER BY %4")
.arg(with_endtime[i]).arg(utc_offset).arg(utc_offset)
.arg(order).toLocal8Bit());
}
for (uint i = 0; i < sizeof(without_endtime)/sizeof(char*); i++)
{
updates_ba.push_back(
QString("UPDATE %1 "
"SET starttime = starttime + interval %2 minute "
"ORDER BY %3")
.arg(without_endtime[i]).arg(utc_offset).arg(order)
.toLocal8Bit());
}
}
// Convert update ByteArrays to NULL terminated char**
QList<QByteArray>::const_iterator it = updates_ba.begin();
vector<const char*> updates;
for (; it != updates_ba.end(); ++it)
updates.push_back((*it).constData());
updates.push_back(NULL);
// do the actual update
if (!performActualUpdate(&updates[0], "1304", dbver))
return false;
}
return true;
}

0 comments on commit 92bf53d

Please sign in to comment.