Permalink
Browse files

This changes the internal representation of time to UTC.

Using UTC rather than localtime makes it possible to record programs during daylight savings time changes without overly complicating the code.

Unfortunately, the QDateTime initializers all either set the DateSpec to localtime or they set it do undefined. This means you can not use QDateTime::setTime_t(), QDateTime::currentDateTime(), QDateTime::fromString(), QDateTime::fromTime_t(), QDateTime::setDate(), QDateTime::setTime(), or QDateTime::setMSecsSinceEpoch() directly unless you follow it with a QDateTime::toUTC() or QDateTime::setDateSpec((Qt::UTC) depending on which method you use. You can use the QDateTime(QDate,QTime,Qt::TimeSpec) constructor, but only if you specify the Qt::TimeSpec.

To make time manipulation in UTC easier given these constraints several utility function have been to the MythDate namespace (currently these live in libmythbase/util.{h,cpp}.

QDateTime as_utc(const QDateTime&) -- Returns a copy of the QDateTime with the TimeSpec set to Qt::UTC, this can be used when pulling DATETIME values from the database. For Example, QDateTime tm = as_utc(query.value(0).toDateTime());

QDateTime current(bool stripped=false) -- Returns the current date and time in UTC. If stripped is set to true the millisecond portion of the time is stripped.

QString current_iso_string(bool stripped=false) -- Returns current(stripped).toString(Qt::ISODate). Purely for convenience.

QDateTime fromTime_t(uint s) -- Returns a QDateTime in UTC initialized from a time_t.

QDateTime fromString(const QString&) -- Returns a QDateTime in UTC initialized from a string in either Qt::ISODate format or "yyyyMMddhhmmss" format.

QDateTime fromString(const QString &date, const QString &format) -- Returns a QDateTime in UTC initialized using an arbitrary format, such as RFC822.

QString toString(const QDateTime &, uint format) -- Returns a formatted string in one of the MythTV recognized formats. The format should be one or more of the flags in MythDate::Format. These come in two flavors, formats intended for use in the database or filesystem such as kISODate, kFilename, kDatabase default to UTC, while formats intended for display default to local time. You can override these defaults with the kOverrideUTC and kOverrideLocal flags.

Traditionally MythTV has not set the timespec to Qt::UTC when dealing with UTC time, this presents problems when comparing times in local time to times in UTC. With the internal represetation of time in UTC it is important to either use these functions for initializing a QDateTime or to properly set the timespec otherwise time comparisons with times from Qt such as that returned from QFileInto::lastModified() will not work correction. As a corrilary, time represented in UTC with the timespec set correctly will compare correctly with a QDateTime in localtime with the timespec set correctly. So if you use these functions when initializing times represented in UTC you won't have any headaches dealing with the times returned from Qt functions.

Since Qt returns times in localtime from it's various functions you will need to convert these to UTC when saving them in a variable for later use. This is accomplished with the toUTC() function. For example, QDateTime mod_time = QFileInfo("x.mpg").toUTC(); This is mainly so that people reading your code can safely assume all times are in UTC which saves them from having to figure out from the code whether you are using localtime or UTC. Another reason for doing this is in case the the variable is saved to the database, we want all times in the database to be in UTC for consistency.
  • Loading branch information...
1 parent dd67c15 commit df47df3642149f929374816ec25b0af13f26a392 @daniel-kristjansson daniel-kristjansson committed Aug 20, 2011
Showing with 1,342 additions and 1,273 deletions.
  1. +1 −1 mythplugins/mytharchive/mytharchive/archivesettings.cpp
  2. +1 −1 mythplugins/mytharchive/mytharchive/archiveutil.cpp
  3. +6 −3 mythplugins/mytharchive/mytharchive/importnative.cpp
  4. +8 −5 mythplugins/mytharchive/mytharchive/recordingselector.cpp
  5. +14 −7 mythplugins/mytharchive/mytharchivehelper/main.cpp
  6. +1 −1 mythplugins/mythgallery/mythgallery/iconview.cpp
  7. +13 −17 mythplugins/mythmusic/mythmusic/filescanner.cpp
  8. +6 −6 mythplugins/mythmusic/mythmusic/metadata.cpp
  9. +2 −2 mythplugins/mythmusic/mythmusic/smartplaylist.cpp
  10. +7 −5 mythplugins/mythnetvision/mythnetvision/netsearch.cpp
  11. +7 −5 mythplugins/mythnetvision/mythnetvision/nettree.cpp
  12. +3 −3 mythplugins/mythnetvision/mythnetvision/rsseditor.cpp
  13. +3 −3 mythplugins/mythnews/mythnews/mythnews.cpp
  14. +3 −2 mythplugins/mythnews/mythnews/newssite.cpp
  15. +2 −2 mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
  16. +3 −2 mythplugins/mythzoneminder/mythzoneminder/zmconsole.cpp
  17. +1 −1 mythplugins/mythzoneminder/mythzoneminder/zmsettings.cpp
  18. +1 −1 mythtv/external/FFmpeg/libavformat/isom.h
  19. +1 −1 mythtv/libs/libmyth/filesysteminfo.cpp
  20. +5 −4 mythtv/libs/libmyth/hardwareprofile.cpp
  21. +2 −1 mythtv/libs/libmyth/mythrssmanager.cpp
  22. +1 −1 mythtv/libs/libmyth/netgrabbermanager.cpp
  23. +6 −5 mythtv/libs/libmyth/netutils.cpp
  24. +102 −89 mythtv/libs/libmyth/programinfo.cpp
  25. +11 −15 mythtv/libs/libmyth/programinfo.h
  26. +2 −1 mythtv/libs/libmyth/programtypes.cpp
  27. +0 −7 mythtv/libs/libmyth/programtypes.h
  28. +6 −8 mythtv/libs/libmyth/remoteutil.cpp
  29. +6 −6 mythtv/libs/libmyth/rssparse.cpp
  30. +14 −17 mythtv/libs/libmythbase/dbutil.cpp
  31. +35 −8 mythtv/libs/libmythbase/logging.cpp
  32. +3 −1 mythtv/libs/libmythbase/logging.h
  33. +3 −2 mythtv/libs/libmythbase/mythcdrom-linux.cpp
  34. +3 −3 mythtv/libs/libmythbase/mythcommandlineparser.cpp
  35. +1 −1 mythtv/libs/libmythbase/mythcorecontext.h
  36. +9 −5 mythtv/libs/libmythbase/mythdbcon.cpp
  37. +15 −14 mythtv/libs/libmythbase/mythdownloadmanager.cpp
  38. +2 −2 mythtv/libs/libmythbase/mythsocket.h
  39. +2 −1 mythtv/libs/libmythbase/remotefile.cpp
  40. +2 −2 mythtv/libs/libmythbase/unzip.cpp
  41. +81 −79 mythtv/libs/libmythbase/util.cpp
  42. +43 −21 mythtv/libs/libmythbase/util.h
  43. +9 −8 mythtv/libs/libmythmetadata/metadatacommon.cpp
  44. +2 −1 mythtv/libs/libmythmetadata/metadataimagedownload.cpp
  45. +2 −1 mythtv/libs/libmythmetadata/mythuiimageresults.cpp
  46. +2 −1 mythtv/libs/libmythmetadata/mythuimetadataresults.cpp
  47. +4 −5 mythtv/libs/libmythmetadata/parentalcontrols.cpp
  48. +4 −2 mythtv/libs/libmythmetadata/videometadata.cpp
  49. +20 −18 mythtv/libs/libmythmetadata/videoscan.cpp
  50. +1 −1 mythtv/libs/libmythprotoserver/requesthandler/basehandler.cpp
  51. +2 −2 mythtv/libs/libmythprotoserver/requesthandler/deletethread.cpp
  52. +1 −1 mythtv/libs/libmythprotoserver/requesthandler/fileserverutil.cpp
  53. +1 −0 mythtv/libs/libmythservicecontracts/datacontracts/recording.h
  54. +1 −0 mythtv/libs/libmythservicecontracts/libmythservicecontracts.pro
  55. +4 −3 mythtv/libs/libmythtv/ThreadedFileWriter.cpp
  56. +3 −1 mythtv/libs/libmythtv/channelscan/paneexistingscanimport.h
  57. +4 −3 mythtv/libs/libmythtv/channelscan/scaninfo.cpp
  58. +3 −3 mythtv/libs/libmythtv/commbreakmap.cpp
  59. +38 −61 mythtv/libs/libmythtv/datadirect.cpp
  60. +4 −2 mythtv/libs/libmythtv/datadirect.h
  61. +8 −7 mythtv/libs/libmythtv/dbcheck.cpp
  62. +5 −5 mythtv/libs/libmythtv/eitcache.cpp
  63. +5 −48 mythtv/libs/libmythtv/eithelper.cpp
  64. +0 −1 mythtv/libs/libmythtv/eithelper.h
  65. +6 −6 mythtv/libs/libmythtv/eitscanner.cpp
  66. +2 −2 mythtv/libs/libmythtv/fileringbuffer.cpp
  67. +30 −27 mythtv/libs/libmythtv/jobqueue.cpp
  68. +16 −15 mythtv/libs/libmythtv/livetvchain.cpp
  69. +1 −1 mythtv/libs/libmythtv/mpeg/atsctables.cpp
  70. +5 −7 mythtv/libs/libmythtv/mpeg/atsctables.h
  71. +1 −4 mythtv/libs/libmythtv/mpeg/dvbtables.cpp
  72. +1 −3 mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp
  73. +0 −2 mythtv/libs/libmythtv/mpeg/mpegstreamdata.h
  74. +2 −4 mythtv/libs/libmythtv/mpeg/premieredescriptors.cpp
  75. +3 −3 mythtv/libs/libmythtv/mythplayer.cpp
  76. +4 −4 mythtv/libs/libmythtv/mythsystemevent.cpp
  77. +3 −3 mythtv/libs/libmythtv/osd.cpp
  78. +5 −5 mythtv/libs/libmythtv/playercontext.cpp
  79. +4 −4 mythtv/libs/libmythtv/previewgenerator.cpp
  80. +5 −5 mythtv/libs/libmythtv/previewgeneratorqueue.cpp
  81. +15 −12 mythtv/libs/libmythtv/programdata.cpp
  82. +7 −5 mythtv/libs/libmythtv/recordinginfo.cpp
  83. +32 −21 mythtv/libs/libmythtv/recordingrule.cpp
  84. +9 −17 mythtv/libs/libmythtv/tv_play.cpp
  85. +33 −33 mythtv/libs/libmythtv/tv_rec.cpp
  86. +20 −25 mythtv/libs/libmythtv/tvbrowsehelper.cpp
  87. +0 −4 mythtv/libs/libmythtv/tvbrowsehelper.h
  88. +2 −2 mythtv/libs/libmythtv/visualisations/videovisual.cpp
  89. +3 −1 mythtv/libs/libmythui/mythmainwindow.cpp
  90. +9 −7 mythtv/libs/libmythui/myththemedmenu.cpp
  91. +1 −1 mythtv/libs/libmythui/mythuiclock.cpp
  92. +5 −4 mythtv/libs/libmythui/mythuihelper.cpp
  93. +2 −1 mythtv/libs/libmythui/screensaver-x11.cpp
  94. +2 −1 mythtv/libs/libmythupnp/httprequest.cpp
  95. +2 −1 mythtv/libs/libmythupnp/upnptasksearch.cpp
  96. +19 −19 mythtv/programs/mythbackend/autoexpire.cpp
  97. +1 −1 mythtv/programs/mythbackend/backendutil.cpp
  98. +14 −14 mythtv/programs/mythbackend/encoderlink.cpp
  99. +17 −21 mythtv/programs/mythbackend/housekeeper.cpp
  100. +56 −50 mythtv/programs/mythbackend/httpstatus.cpp
  101. +28 −32 mythtv/programs/mythbackend/mainserver.cpp
  102. +3 −6 mythtv/programs/mythbackend/playbacksock.cpp
  103. +64 −57 mythtv/programs/mythbackend/scheduler.cpp
  104. +3 −3 mythtv/programs/mythbackend/services/channel.cpp
  105. +4 −4 mythtv/programs/mythbackend/services/content.cpp
  106. +2 −2 mythtv/programs/mythbackend/services/dvr.cpp
  107. +4 −4 mythtv/programs/mythbackend/services/guide.cpp
  108. +2 −2 mythtv/programs/mythbackend/services/myth.cpp
  109. +19 −8 mythtv/programs/mythbackend/services/video.cpp
  110. +1 −1 mythtv/programs/mythbackend/upnpcdstv.cpp
  111. +1 −1 mythtv/programs/mythbackend/upnpcdsvideo.cpp
  112. +7 −7 mythtv/programs/mythcommflag/ClassicCommDetector.cpp
  113. +2 −2 mythtv/programs/mythcommflag/CommDetector2.cpp
  114. +5 −5 mythtv/programs/mythcommflag/PrePostRollFlagger.cpp
  115. +11 −12 mythtv/programs/mythcommflag/main.cpp
  116. +23 −28 mythtv/programs/mythfilldatabase/filldata.cpp
  117. +14 −16 mythtv/programs/mythfilldatabase/main.cpp
  118. +5 −4 mythtv/programs/mythfilldatabase/xmltvparser.cpp
  119. +2 −2 mythtv/programs/mythfrontend/globalsettings.cpp
  120. +11 −11 mythtv/programs/mythfrontend/guidegrid.cpp
  121. +17 −12 mythtv/programs/mythfrontend/manualschedule.cpp
  122. +2 −2 mythtv/programs/mythfrontend/mediarenderer.cpp
  123. +10 −10 mythtv/programs/mythfrontend/networkcontrol.cpp
  124. +23 −21 mythtv/programs/mythfrontend/playbackbox.cpp
  125. +5 −7 mythtv/programs/mythfrontend/playbackboxhelper.cpp
  126. +1 −1 mythtv/programs/mythfrontend/playbackboxhelper.h
  127. +14 −10 mythtv/programs/mythfrontend/progdetails.cpp
  128. +7 −7 mythtv/programs/mythfrontend/progfind.cpp
  129. +12 −12 mythtv/programs/mythfrontend/proglist.cpp
  130. +11 −10 mythtv/programs/mythfrontend/proglist_helpers.cpp
  131. +18 −16 mythtv/programs/mythfrontend/programrecpriority.cpp
  132. +9 −7 mythtv/programs/mythfrontend/schedulecommon.cpp
  133. +29 −30 mythtv/programs/mythfrontend/statusbox.cpp
  134. +2 −1 mythtv/programs/mythfrontend/themechooser.cpp
  135. +2 −1 mythtv/programs/mythfrontend/videofilter.cpp
  136. +3 −1 mythtv/programs/mythfrontend/videolist.cpp
  137. +7 −5 mythtv/programs/mythfrontend/viewscheduled.cpp
  138. +5 −3 mythtv/programs/mythfrontend/viewschedulediff.cpp
  139. +16 −8 mythtv/programs/mythlcdserver/lcdprocclient.cpp
  140. +1 −1 mythtv/programs/mythpreviewgen/main.cpp
  141. +16 −11 mythtv/programs/mythshutdown/main.cpp
  142. +5 −5 mythtv/programs/mythtranscode/main.cpp
  143. +4 −3 mythtv/programs/mythtranscode/mpeg2fix.cpp
  144. +5 −5 mythtv/programs/mythtranscode/transcode.cpp
  145. +2 −1 mythtv/programs/mythtv-setup/main.cpp
  146. +8 −6 mythtv/programs/mythwelcome/welcomedialog.cpp
@@ -176,7 +176,7 @@ static HostComboBox *MythArchiveDateFormat()
HostComboBox *gc = new HostComboBox("MythArchiveDateFormat");
gc->setLabel(QObject::tr("Date format"));
- QDate sampdate = QDate::currentDate();
+ QDate sampdate = MythDate::current().toLocalTime().date();
QString sampleStr =
QObject::tr("Samples are shown using today's date.");
@@ -191,7 +191,7 @@ ProgramInfo *getProgramInfoForFile(const QString &inFile)
if (bIsMythRecording)
{
uint chanid = chanID.toUInt();
- QDateTime recstartts = myth_dt_from_string(startTime);
+ QDateTime recstartts = MythDate::fromString(startTime);
pinfo = new ProgramInfo(chanid, recstartts);
if (pinfo->GetChanID())
{
@@ -18,6 +18,7 @@
#include <mythdialogbox.h>
#include <mythsystem.h>
#include <exitcodes.h>
+#include <util.h>
// mytharchive
#include "importnative.h"
@@ -84,7 +85,7 @@ static bool loadDetailsFromXML(const QString &filename, FileDetails *details)
details->subtitle = e.text();
if (e.tagName() == "starttime")
- details->startTime = QDateTime::fromString(e.text(), Qt::ISODate);
+ details->startTime = MythDate::fromString(e.text());
if (e.tagName() == "description")
details->description = e.text();
@@ -248,7 +249,8 @@ void ArchiveFileSelector::itemSelected(MythUIButtonListItem *item)
m_xmlFile = m_curDirectory + "/" + fileData->filename;
m_progTitle->SetText(m_details.title);
m_progSubtitle->SetText(m_details.subtitle);
- m_progStartTime->SetText(m_details.startTime.toString("dd MMM yy (hh:mm)"));
+ m_progStartTime->SetText(m_details.startTime.toLocalTime()
+ .ToString("dd MMM yy (hh:mm)"));
}
else
{
@@ -352,7 +354,8 @@ bool ImportNative::Create(void)
m_progTitle_text->SetText(m_details.title);
- m_progDateTime_text->SetText(m_details.startTime.toString("dd MMM yy (hh:mm)"));
+ m_progDateTime_text->SetText(m_details.startTime.toLocalTime()
+ .ToString("dd MMM yy (hh:mm)"));
m_progDescription_text->SetText(
(m_details.subtitle == "" ? m_details.subtitle + "\n" : "") + m_details.description);
@@ -264,8 +264,8 @@ void RecordingSelector::titleChanged(MythUIButtonListItem *item)
m_titleText->SetText(p->GetTitle());
if (m_datetimeText)
- m_datetimeText->SetText(p->GetScheduledStartTime()
- .toString("dd MMM yy (hh:mm)"));
+ m_datetimeText->SetText(p->GetScheduledStartTime().toLocalTime()
+ .ToString("dd MMM yy (hh:mm)"));
if (m_descriptionText)
{
@@ -362,8 +362,10 @@ void RecordingSelector::OKPressed()
a->title = p->GetTitle();
a->subtitle = p->GetSubtitle();
a->description = p->GetDescription();
- a->startDate = p->GetScheduledStartTime().toString("dd MMM yy");
- a->startTime = p->GetScheduledStartTime().toString("(hh:mm)");
+ a->startDate = p->GetScheduledStartTime()
+ .toLocalTime().ToString("dd MMM yy");
+ a->startTime = p->GetScheduledStartTime()
+ .toLocalTime().ToString("(hh:mm)");
a->size = p->GetFilesize();
a->filename = p->GetPlaybackURL(false, true);
a->hasCutlist = p->HasCutlist();
@@ -410,7 +412,8 @@ void RecordingSelector::updateRecordingList(void)
MythUIButtonListItem* item = new MythUIButtonListItem(
m_recordingButtonList,
p->GetTitle() + " ~ " +
- p->GetScheduledStartTime().toString("dd MMM yy (hh:mm)"));
+ p->GetScheduledStartTime().toLocalTime()
+ .ToString("dd MMM yy (hh:mm)"));
item->setCheckable(true);
if (m_selectedList.indexOf((ProgramInfo *) p) != -1)
{
@@ -275,14 +275,16 @@ static int burnISOImage(int mediaType, bool bEraseDVDRW, bool nativeFormat)
static int doBurnDVD(int mediaType, bool bEraseDVDRW, bool nativeFormat)
{
- gCoreContext->SaveSetting("MythArchiveLastRunStart",
- QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm"));
+ gCoreContext->SaveSetting(
+ "MythArchiveLastRunStart",
+ MythDate::toString(MythDate::current(), MythDate::kDatabase));
gCoreContext->SaveSetting("MythArchiveLastRunStatus", "Running");
int res = burnISOImage(mediaType, bEraseDVDRW, nativeFormat);
- gCoreContext->SaveSetting("MythArchiveLastRunEnd",
- QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm"));
+ gCoreContext->SaveSetting(
+ "MythArchiveLastRunEnd",
+ MythDate::toString(MythDate::current(), MythDate::kDatabase));
gCoreContext->SaveSetting("MythArchiveLastRunStatus", "Success");
return res;
}
@@ -1754,13 +1756,18 @@ static void clearArchiveTable(void)
static int doNativeArchive(const QString &jobFile)
{
gCoreContext->SaveSetting("MythArchiveLastRunType", "Native Export");
- gCoreContext->SaveSetting("MythArchiveLastRunStart", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm"));
+ gCoreContext->SaveSetting(
+ "MythArchiveLastRunStart",
+ MythDate::toString(MythDate::current(), MythDate::kDatabase));
gCoreContext->SaveSetting("MythArchiveLastRunStatus", "Running");
NativeArchive na;
int res = na.doNativeArchive(jobFile);
- gCoreContext->SaveSetting("MythArchiveLastRunEnd", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm"));
- gCoreContext->SaveSetting("MythArchiveLastRunStatus", (res == 0 ? "Success" : "Failed"));
+ gCoreContext->SaveSetting(
+ "MythArchiveLastRunEnd",
+ MythDate::toString(MythDate::current(), MythDate::kDatabase));
+ gCoreContext->SaveSetting("MythArchiveLastRunStatus",
+ (res == 0 ? "Success" : "Failed"));
// clear the archiveitems table if succesful
if (res == 0)
@@ -1123,7 +1123,7 @@ void IconView::HandleImport(void)
// Makes import directory samba/windows friendly (no colon)
QString idirname = m_currDir + "/" +
- QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss");
+ MythDate::current().ToString("yyyy-MM-dd_hh-mm-ss");
importdir.mkdir(idirname);
importdir.setPath(idirname);
@@ -200,26 +200,22 @@ int FileScanner::GetDirectoryId(const QString &directory, const int &parentid)
*
* \returns True if file has been modified, otherwise false
*/
-bool FileScanner::HasFileChanged(const QString &filename, const QString &date_modified)
+bool FileScanner::HasFileChanged(
+ const QString &filename, const QString &date_modified)
{
- struct stat stbuf;
-
- QByteArray fname = filename.toLocal8Bit();
- if (stat(fname.constData(), &stbuf) == 0)
+ QFileInfo fi(filename);
+ QDateTime dt = fi.lastModified();
+ if (dt.isValid())
{
- if (date_modified.isEmpty() ||
- stbuf.st_mtime >
- (time_t)QDateTime::fromString(date_modified,
- Qt::ISODate).toTime_t())
- {
- return true;
- }
+ QDateTime old_dt = MythDate::fromString(date_modified);
+ return !old_dt.isValid() || (dt > old_dt);
}
- else {
+ else
+ {
LOG(VB_GENERAL, LOG_ERR, QString("Failed to stat file: %1")
.arg(filename));
+ return false;
}
- return false;
}
/*!
@@ -617,7 +613,7 @@ void FileScanner::SearchDir(QString &directory)
{
if (*iter == kFileSystem)
AddFileToDB(iter.key());
- else if (*iter == kDatabase)
+ else if (*iter == MythDate::kDatabase)
RemoveFileFromDB(iter.key ());
else if (*iter == kNeedUpdate)
UpdateFileInDB(iter.key());
@@ -685,7 +681,7 @@ void FileScanner::ScanMusic(MusicLoadedMap &music_files)
{
if ((iter = music_files.find(name)) != music_files.end())
{
- if (music_files[name] == kDatabase)
+ if (music_files[name] == MythDate::kDatabase)
{
if (file_checking)
{
@@ -767,7 +763,7 @@ void FileScanner::ScanArtwork(MusicLoadedMap &music_files)
{
if ((iter = music_files.find(name)) != music_files.end())
{
- if (music_files[name] == kDatabase)
+ if (music_files[name] == MythDate::kDatabase)
{
if (file_checking)
{
@@ -144,7 +144,7 @@ void Metadata::UpdateModTime() const
query.prepare("UPDATE music_songs SET date_modified = :DATE_MOD "
"WHERE song_id= :ID ;");
- query.bindValue(":DATE_MOD", QDateTime::currentDateTime());
+ query.bindValue(":DATE_MOD", MythDate::current());
query.bindValue(":ID", m_id);
if (!query.exec())
@@ -456,11 +456,11 @@ void Metadata::dumpToDatabase()
query.bindValue(":FILENAME", sqlfilename);
query.bindValue(":RATING", m_rating);
query.bindValue(":FORMAT", m_format);
- query.bindValue(":DATE_MOD", QDateTime::currentDateTime());
+ query.bindValue(":DATE_MOD", MythDate::current());
query.bindValue(":PLAYCOUNT", m_playcount);
if (m_id < 1)
- query.bindValue(":DATE_ADD", QDateTime::currentDateTime());
+ query.bindValue(":DATE_ADD", MythDate::current());
else
query.bindValue(":ID", m_id);
@@ -699,8 +699,8 @@ void Metadata::toMap(MetadataMap &metadataMap)
else
metadataMap["length"] = QString().sprintf("%02d:%02d", em, es);
- metadataMap["lastplayed"] = MythDateTimeToString(m_lastplay,
- kDateFull | kSimplify | kAddYear);
+ metadataMap["lastplayed"] = MythDate::toString(m_lastplay,
+ MythDate::kDateFull | MythDate::kSimplify | MythDate::kAddYear);
metadataMap["playcount"] = QString::number(m_playcount);
metadataMap["filename"] = m_filename;
@@ -726,7 +726,7 @@ void Metadata::incRating()
void Metadata::setLastPlay()
{
- m_lastplay = QDateTime::currentDateTime();
+ m_lastplay = MythDate::current();
m_changed = true;
}
@@ -112,7 +112,7 @@ static QString evaluateDateValue(QString sDate)
{
if (sDate.startsWith("$DATE"))
{
- QDate date = QDate::currentDate();
+ QDate date = MythDate::current().toLocalTime().date();
if (sDate.length() > 9)
{
@@ -2437,7 +2437,7 @@ SmartPLDateDialog::SmartPLDateDialog(MythMainWindow *parent, const char *name)
hbox->addWidget(caption);
// fixed date widgets
- QDate date = QDate::currentDate();
+ QDate date = MythDate::current().toLocalTime().date();
hbox = new Q3HBoxLayout(vbox, (int)(10 * hmult));
fixedRadio = new MythRadioButton(this, "nopopsize");
fixedRadio->setText(tr("Fixed Date"));
@@ -23,6 +23,7 @@
#include <metadata/videoutils.h>
#include <rssparse.h>
#include <mythcoreutil.h>
+#include <util.h>
#include "netsearch.h"
#include "netcommon.h"
@@ -314,7 +315,7 @@ void NetSearch::cleanCacheDir()
LOG(VB_GENERAL, LOG_DEBUG, QString("Deleting file %1").arg(filename));
QFileInfo fi(filename);
QDateTime lastmod = fi.lastModified();
- if (lastmod.addDays(7) < QDateTime::currentDateTime())
+ if (lastmod.addDays(7) < MythDate::current())
QFile::remove(filename);
}
}
@@ -520,10 +521,11 @@ void NetSearch::streamWebVideo()
return;
}
- GetMythMainWindow()->HandleMedia("Internal", item->GetMediaURL(),
- item->GetDescription(), item->GetTitle(), item->GetSubtitle(), QString(),
- item->GetSeason(), item->GetEpisode(), QString(), item->GetTime().toInt(),
- item->GetDate().toString("yyyy"));
+ GetMythMainWindow()->HandleMedia(
+ "Internal", item->GetMediaURL(),
+ item->GetDescription(), item->GetTitle(), item->GetSubtitle(),
+ QString(), item->GetSeason(), item->GetEpisode(), QString(),
+ item->GetTime().toInt(), item->GetDate().ToString("yyyy"));
}
void NetSearch::showWebVideo()
@@ -4,6 +4,7 @@
#include <QtAlgorithms>
// myth
+#include <util.h>
#include <mythdb.h>
#include <mythcontext.h>
#include <mythdirs.h>
@@ -205,7 +206,7 @@ void NetTree::cleanCacheDir()
LOG(VB_GENERAL, LOG_DEBUG, QString("Deleting file %1").arg(filename));
QFileInfo fi(filename);
QDateTime lastmod = fi.lastModified();
- if (lastmod.addDays(7) < QDateTime::currentDateTime())
+ if (lastmod.addDays(7) < MythDate::current())
QFile::remove(filename);
}
}
@@ -772,10 +773,11 @@ void NetTree::streamWebVideo()
return;
}
- GetMythMainWindow()->HandleMedia("Internal", item->GetMediaURL(),
- item->GetDescription(), item->GetTitle(), item->GetSubtitle(), QString(),
- item->GetSeason(), item->GetEpisode(), QString(), item->GetTime().toInt(),
- item->GetDate().toString("yyyy"));
+ GetMythMainWindow()->HandleMedia(
+ "Internal", item->GetMediaURL(),
+ item->GetDescription(), item->GetTitle(), item->GetSubtitle(),
+ QString(), item->GetSeason(), item->GetEpisode(), QString(),
+ item->GetTime().toInt(), item->GetDate().ToString("yyyy"));
}
void NetTree::showWebVideo()
@@ -164,7 +164,7 @@ void RSSEditPopup::parseAndSave(void)
removeFromDB(m_urlText, VIDEO_PODCAST);
if (insertInDB(new RSSSite(title, filename, VIDEO_PODCAST,
- desc, link, author, download, QDateTime::currentDateTime())))
+ desc, link, author, download, MythDate::current())))
emit saving();
Close();
}
@@ -271,7 +271,7 @@ void RSSEditPopup::slotSave(QNetworkReply* reply)
else
download = false;
- QDateTime updated = QDateTime::currentDateTime();
+ QDateTime updated = MythDate::current();
QString filename("");
if (file.isEmpty())
@@ -309,7 +309,7 @@ void RSSEditPopup::slotSave(QNetworkReply* reply)
HttpComms::getHttpFile(filename, thumbnailURL, 20000, 1, 2);
}
if (insertInDB(new RSSSite(title, filename, VIDEO_PODCAST, description, link,
- author, download, QDateTime::currentDateTime())))
+ author, download, MythDate::current())))
emit saving();
}
Close();
@@ -189,7 +189,7 @@ void MythNews::loadSites(void)
QString name = query.value(0).toString();
QString url = query.value(1).toString();
QString icon = query.value(2).toString();
- QDateTime time; time.setTime_t(query.value(3).toUInt());
+ QDateTime time = MythDate::fromTime_t(query.value(3).toUInt());
bool podcast = query.value(4).toInt();
m_NewsSites.push_back(new NewsSite(name, url, time, podcast));
}
@@ -452,8 +452,8 @@ void MythNews::updateInfoView(MythUIButtonListItem *selected)
QString text(tr("Updated") + " - ");
QDateTime updated(site->lastUpdated());
if (updated.toTime_t() != 0) {
- text += MythDateTimeToString(site->lastUpdated(),
- kDateTimeFull | kSimplify);
+ text += MythDate::toString(site->lastUpdated(),
+ MythDate::kDateTimeFull | MythDate::kSimplify);
}
else
text += tr("Unknown");
Oops, something went wrong.

0 comments on commit df47df3

Please sign in to comment.