Mon, 23 Sep 2019 14:06:36 +0300
added regular expressions for the parser
1 | 1 | #include <QString> |
2 | #include <time.h> | |
3 | #include "version.h" | |
4 | #include "hginfo.h" | |
5 | ||
6 | static QString makeVersionString(const Version &version) | |
7 | { | |
8 | QString result = QString::number(version.major) + "." + QString::number(version.minor); | |
9 | if (version.patch != 0) { | |
10 | result += "."; | |
11 | result += QString::number(version.patch); | |
12 | } | |
13 | return result; | |
14 | } | |
15 | ||
16 | const QString& fullVersionString() | |
17 | { | |
18 | #ifdef HG_DATE_VERSION | |
19 | if (::buildType != ReleaseBuild) { | |
20 | static const QString result = makeVersionString(::version) + "-" HG_DATE_VERSION; | |
21 | return result; | |
22 | } | |
23 | #else | |
24 | static const QString result = makeVersionString(::version); | |
25 | return result; | |
26 | #endif | |
27 | } | |
28 | ||
29 | static QString makeCommitTimeString() | |
30 | { | |
31 | QString result; | |
32 | #ifdef HG_DATE_TIME | |
33 | { | |
34 | char buffer[100]; | |
35 | constexpr time_t timestamp = HG_DATE_TIME; | |
36 | strftime (buffer, sizeof buffer, "%d %b %Y", localtime (×tamp)); | |
37 | result += buffer; | |
38 | } | |
39 | #endif | |
40 | return result; | |
41 | } | |
42 | ||
43 | const QString &commitTimeString() | |
44 | { | |
45 | static QString result = makeCommitTimeString(); | |
46 | return result; | |
47 | } |