qdate from string with one or two day digits and one or two month digits
Can't figure out how to specify format for QDate::fromString call where the string is a date with one or two digits for day and month. For example: 1/12/2018 or 01/12/2018, or 1/1/2018 vs 01/01/2018. Advice is greatly appreciated.
Thanks
Re: qdate from string with one or two day digits and one or two month digits
I am afraid that you have to call 4 times QDate::fromString (with different params for each case) and verify it by QDate::isValid...
Re: qdate from string with one or two day digits and one or two month digits
So don't use QDate::fromString().
Code:
if ( dateList.length() == 3 )
{
int month = dateList.at( 0 ).toInt();
int day = dateList.at( 1 ).toInt();
int year = dateList.at( 2 ).toInt();
date.setDate( year, month, day );
}
else
// error