localized translated autoname function using QDate and QTime or QDateTime
-
He guys, I am trying to figure out if I can use QDateTime to come up with an autoname function that I know will always produce a unique name which is both translatable and localized. I was thinking something like: YYYY-MM-DDD-HHMMSS. What might that look like using QDateTime? Are there any examples of something similar online?
-
@Circuits said in localized translated autoname function using QDate and QTime or QDateTime:
So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS?
yes, with
QDateTime::toString()
Most of the rest of the world uses the YYYY/MM/DD format do they not?
The world settled on the ISO 8601 format that you can get with
dateTime.toString(Qt::ISODate)
-
@Circuits said in localized translated autoname function using QDate and QTime or QDateTime:
What might that look like using QDateTime?
Well it would look like whatever
QDateTime
says for your pattern. (Yours btw I don't think is valid, maybe you hadddd MMMM
in mind?) Note that https://doc.qt.io/qt-5/qdatetime.html#toString-2 states:Note: If localized month and day names are desired, please switch to using QLocale::system().toString() as QDateTime methods shall change to use English (C locale) names at Qt 6.
-
@JonB So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS? Seems odd because any other format would require some kind of localization as it would be an American-centric format. Most of the rest of the world uses the YYYY/MM/DD format do they not?
-
@Circuits said in localized translated autoname function using QDate and QTime or QDateTime:
So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS?
yes, with
QDateTime::toString()
Most of the rest of the world uses the YYYY/MM/DD format do they not?
The world settled on the ISO 8601 format that you can get with
dateTime.toString(Qt::ISODate)
-
@Circuits said in localized translated autoname function using QDate and QTime or QDateTime:
So QDateTime does not provide the ability to produce: YYYY/MM/DD/HHMMSS?
In addition to what @VRonin wrote. It certainly does. If you clicked the link I gave you would see it recognises many such patterns, that's the whole point. The question is precisely which/what you are wanting.