Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.11.2
-
None
-
-
5
-
91140eb7268bc36efceef0459e7b124ce333829e (qt/qtbase/dev)
-
Qt6_Foundation_Sprint 17, Qt6_Foundation_Sprint 18, Qt6_Foundation_Sprint 19, Qt6_Foundation_Sprint 20, Qt6_Foundation_Sprint 21
Description
QDate QDate::fromString(const QString &string, const QString &format) const
cannot parse dates with negative year, although the documentation states that yyyy The year as four digit number. If the year is negative, a minus sign is prepended in addition.
QDate::fromString( "-0010-01-01", "yyyy-MM-dd" );
results in an invalid date.
Instead
QString QDate::toString(const QString &format) const
correctly handles dates with negative years.
In fact
QDate( -10, 1, 1 ).toString( "yyyy-MM-dd" );
correctly creates the string "-0010-01-01".
Attachments
Issue Links
- relates to
-
QTBUG-82886 Qt::DefaultLocaleShortDate / QLocale::ShortFormat date parsing doesn't deal with 4-digit years
- Open
-
QTBUG-84349 QDateTimeParser wrongly accepts a sign in a month field MM
- Closed
For Gerrit Dashboard: QTBUG-84334 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
312777,13 | adapt QDate::fromString to better align with documentation | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
315029,24 | Adapt QDate::fromString() to accept negative year numbers | dev | qt/qtbase | Status: MERGED | +2 | 0 |
316087,12 | Add unit tests for qdatetimeparser | dev | qt/qtbase | Status: MERGED | +2 | 0 |
316622,19 | Add unit tests for QDateTimeParser internals | dev | qt/qtbase | Status: MERGED | +2 | 0 |