QDateTimeFromString question
-
If I call:
m_DateTime = QDateTime::fromString(strDateTime, "yyyy-MM-ddThh:mm:ss");with input of "2023-12-06T02:00:56", it works, but if I call it with input of "2023-12-06T02:00:56.481" it returns an invalid QDateTime.
Should I expect that? I would have expected it to be tolerant of trailing sub-seconds?
-
If I call:
m_DateTime = QDateTime::fromString(strDateTime, "yyyy-MM-ddThh:mm:ss");with input of "2023-12-06T02:00:56", it works, but if I call it with input of "2023-12-06T02:00:56.481" it returns an invalid QDateTime.
Should I expect that? I would have expected it to be tolerant of trailing sub-seconds?
@Perdrix said in QDateTimeFromString question:
Should I expect that? I would have expected it to be tolerant of trailing sub-seconds?
Yes, you should expect that. If there's trailing milliseconds, you should add
.zzz(or.z) to the format string. See https://doc.qt.io/qt-6/qtime.html#fromString-4Cheers.
-
@Perdrix said in QDateTimeFromString question:
Should I expect that? I would have expected it to be tolerant of trailing sub-seconds?
Yes, you should expect that. If there's trailing milliseconds, you should add
.zzz(or.z) to the format string. See https://doc.qt.io/qt-6/qtime.html#fromString-4Cheers.
@Paul-Colby Thank you