Last active
September 17, 2021 05:06
-
-
Save Vaiz/4e10723007326f8f2dd1 to your computer and use it in GitHub Desktop.
Build time in QDateTime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QDateTime buildDateTime() | |
{ | |
QDateTime dateTime; | |
dateTime.setDate(QLocale("en_US").toDate(QString(__DATE__).simplified(), "MMM d yyyy")); | |
dateTime.setTime(QTime::fromString(__TIME__, "hh:mm:ss")); | |
return dateTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot! QLocale is very important! An alternative constant can be generated using:
const QDateTime BuildDateTime = QDateTime( QLocale("en_US").toDate(QString(__DATE__).simplified(), "MMM d yyyy"), QTime::fromString(__TIME__, "hh:mm:ss"));