I have the following situation:
QDate fixDate = QDate::fromString(QString("270912"), "ddMMyy");
the year returned is 1912. I do not understand why and how get the correct year.
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Qt always interprets a two-digit year as
19yy.So it’s best to modify the input string to look like
YYYY.Note: parsing it as YY and adding 100 years fails on Feb 29, 2000. ‘22900’ is seen as February 29, 1900, but – surprise! – in the Gregorian calendar 1900 is not a leap year. So you get an invalid QDate, which remains invalid after adding 100 years to it.