0

In a Qt5 C++ project the .pro have the following

DATE = $$system(echo %DATE%)
...
DEFINES += DATETIME_VERSION=\"$${DATETIME}\"

It get the date, does some formatting and defines a variable that is read in C++ later.

That works fine on Windows. But not on macOS.

I do that because I don't know a qmake function that returns the date.

So to get date on macOS I think I can go around using date command. But I will have to customize the output to make it similar to what I'm getting on Windows. That's too much work.

I'm wondering if is possible to call a python scrip from qmake? So maybe it will be possible to have the same python scrip being used on Windows/macOS.

Or, is there a smarter way to solve this problem?

References:

How to print a date in a regular format?

https://doc.qt.io/archives/qt-4.8/qmake-function-reference.html#system-command

KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • Does this answer your question? [Get the date with qmake](https://stackoverflow.com/questions/29753345/get-the-date-with-qmake) – mugiseyebrows Apr 23 '22 at 08:59
  • It does not answer, `_DATE_` seems to have different format depending on OS language (try CN/EN Windows). And month is not a number. – KcFnMi Apr 23 '22 at 09:19

0 Answers0