Skip to content

Instantly share code, notes, and snippets.

@Vaiz
Last active September 17, 2021 05:06
Show Gist options
  • Save Vaiz/4e10723007326f8f2dd1 to your computer and use it in GitHub Desktop.
Save Vaiz/4e10723007326f8f2dd1 to your computer and use it in GitHub Desktop.
Build time in QDateTime
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;
}
@raphaelpereira
Copy link

raphaelpereira commented Sep 29, 2017

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"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment