Skip to content

Commit

Permalink
Change MythDate::toString() to return an empty string for invalid inp…
Browse files Browse the repository at this point in the history
…uts.

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 .
  • Loading branch information
gigem committed Mar 21, 2013
1 parent 841ff3a commit 24c64a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mythtv/libs/libmythbase/mythdate.cpp
Expand Up @@ -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)))
{
Expand Down Expand Up @@ -118,6 +121,9 @@ QString toString(const QDate &date, uint format)
{
QString result;

if (!date.isValid())
return result;

if (format & (kDateFull | kDateShort))
{
QString stringformat;
Expand Down

0 comments on commit 24c64a1

Please sign in to comment.