From 24c64a1e0bc36fc2d2dbd8d54bf30ac9fe387a85 Mon Sep 17 00:00:00 2001 From: David Engel Date: Thu, 21 Mar 2013 15:05:18 -0500 Subject: [PATCH] Change MythDate::toString() to return an empty string for invalid inputs. It's possible a "0000-00-00 00:00:00" might be somewhat acceptable in some rare cases because the all 0s value obviously represents a special value. The UTC to local conversions added in 0.26, however, now causes it to change to a less obviously special, and perhaps even misledaing, not all 0s value. Since MythDate::toString() was a Myth-specific replacement for QDateTime::toString() and QDate::toString() and those functions return an empty string for invalid inputs, we probably should too. Fixes #11405 . --- mythtv/libs/libmythbase/mythdate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mythtv/libs/libmythbase/mythdate.cpp b/mythtv/libs/libmythbase/mythdate.cpp index 2562d72ae58..c30cbda5286 100644 --- a/mythtv/libs/libmythbase/mythdate.cpp +++ b/mythtv/libs/libmythbase/mythdate.cpp @@ -72,6 +72,9 @@ QString toString(const QDateTime &raw_dt, uint format) { QString result; + if (!raw_dt.isValid()) + return result; + // if no format is set default to UTC for ISO/file/DB dates. if (!((format & kOverrideUTC) || (format & kOverrideLocal))) { @@ -118,6 +121,9 @@ QString toString(const QDate &date, uint format) { QString result; + if (!date.isValid()) + return result; + if (format & (kDateFull | kDateShort)) { QString stringformat;