Skip to content

Commit

Permalink
Prefer QDate::startOfDay() over QDateTime(const QDate &)
Browse files Browse the repository at this point in the history
The latter can be invalid if midnight is skipped by a spring-forward.

Change-Id: Ibf98d165557229f19622774ebf9a27bb0911c7a7
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
ediosyncratic committed Dec 9, 2019
1 parent c27123d commit 8310981
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/corelib/time/qdatetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5214,7 +5214,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
if (!date.isValid())
return QDateTime();
if (size == 10)
return QDateTime(date);
return date.startOfDay();

Qt::TimeSpec spec = Qt::LocalTime;
QStringRef isoString(&string);
Expand Down

0 comments on commit 8310981

Please sign in to comment.