[mythtv] [PATCH] implemented time offset for mythfilldatabase
Christian Hoenig
mythtv-dev@snowman.net
Mon, 18 Nov 2002 16:37:30 +0100
Ok, maybe this is a better implementation of the addTimeOffset() ;-)
void addTimeOffset(QString ×tr, int config_off, QString offset )
{
bool ok;
int off = offset.stripWhiteSpace().left(3).toInt(&ok, 10);
if (ok && (off != config_off))
{
int diff = config_off - off;
int year, month, day, hour, min, sec;
if (timestr.length() == 14)
{
year = timestr.left(4).toInt(&ok, 10);
month = timestr.mid(4,2).toInt(&ok, 10);
day = timestr.mid(6,2).toInt(&ok, 10);
hour = timestr.mid(8,2).toInt(&ok, 10);
min = timestr.mid(10,2).toInt(&ok, 10);
sec = timestr.mid(12,2).toInt(&ok, 10);
}
else if (timestr.length() == 12)
{
year = timestr.left(2).toInt(&ok, 10);
month = timestr.mid(2,2).toInt(&ok, 10);
day = timestr.mid(4,2).toInt(&ok, 10);
hour = timestr.mid(6,2).toInt(&ok, 10);
min = timestr.mid(8,2).toInt(&ok, 10);
sec = timestr.mid(10,2).toInt(&ok, 10);
}
QDateTime dt = QDateTime(QDate (year, month, day),QTime(hour, min, sec));
dt = dt.addSecs(diff * 60 * 60);
timestr = dt.toString("yyyyMMddhhmmss");
}
}