summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qdatetime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/time/qdatetime.cpp')
-rw-r--r--src/corelib/time/qdatetime.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 15654117a9..c2f0601ebf 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1860,9 +1860,9 @@ QT_WARNING_POP
be given in the user's local language. It is only possible to use the English
names if the user's language is English.
- All other input characters will be treated as text. Any sequence
- of characters that are enclosed in single quotes will also be
- treated as text and will not be used as an expression. For example:
+ All other input characters will be treated as text. Any non-empty sequence
+ of characters enclosed in single quotes will also be treated (stripped of
+ the quotes) as text and not be interpreted as expressions. For example:
\snippet code/src_corelib_tools_qdatetime.cpp 1
@@ -2230,11 +2230,11 @@ QT_WARNING_POP
\row \li t \li The timezone (for example "CEST")
\endtable
- Any sequence of characters enclosed in single quotes will be included
- verbatim in the output string (stripped of the quotes), even if it contains
- formatting characters. Two consecutive single quotes ("''") are replaced by
- a single quote in the output. All other characters in the format string are
- included verbatim in the output string.
+ Any non-empty sequence of characters enclosed in single quotes will be
+ included verbatim in the output string (stripped of the quotes), even if it
+ contains formatting characters. Two consecutive single quotes ("''") are
+ replaced by a single quote in the output. All other characters in the format
+ string are included verbatim in the output string.
Formats without separators (e.g. "ddMM") are supported but must be used with
care, as the resulting strings aren't always reliably readable (e.g. if "dM"
@@ -2634,9 +2634,9 @@ QT_WARNING_POP
\row \li t \li the timezone (for example "CEST")
\endtable
- All other input characters will be treated as text. Any sequence
- of characters that are enclosed in single quotes will also be
- treated as text and not be used as an expression.
+ All other input characters will be treated as text. Any non-empty sequence
+ of characters enclosed in single quotes will also be treated (stripped of
+ the quotes) as text and not be interpreted as expressions.
\snippet code/src_corelib_tools_qdatetime.cpp 6
@@ -5556,9 +5556,9 @@ QT_WARNING_POP
See QDate::fromString() and QTime::fromString() for the expressions
recognized in the format string to represent parts of the date and time.
- All other input characters will be treated as text. Any sequence of
- characters that are enclosed in single quotes will also be treated as text
- and not be used as an expression.
+ All other input characters will be treated as text. Any non-empty sequence
+ of characters enclosed in single quotes will also be treated (stripped of
+ the quotes) as text and not be interpreted as expressions.
\snippet code/src_corelib_tools_qdatetime.cpp 12
@@ -5613,13 +5613,12 @@ QT_WARNING_POP
QDateTime QDateTime::fromString(const QString &string, const QString &format, QCalendar cal)
{
#if QT_CONFIG(datetimeparser)
- QTime time;
- QDate date;
+ QDateTime datetime;
QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
- if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
- return QDateTime(date, time);
+ if (dt.parseFormat(format) && dt.fromString(string, &datetime))
+ return datetime;
#else
Q_UNUSED(string);
Q_UNUSED(format);