Sat, 01 Feb 2020 15:49:28 +0200
translations
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
1 | 19 | #include <QString> |
20 | #include <time.h> | |
21 | #include "version.h" | |
22 | #include "hginfo.h" | |
23 | ||
24 | static QString makeVersionString(const Version &version) | |
25 | { | |
26 | QString result = QString::number(version.major) + "." + QString::number(version.minor); | |
27 | if (version.patch != 0) { | |
28 | result += "."; | |
29 | result += QString::number(version.patch); | |
30 | } | |
31 | return result; | |
32 | } | |
33 | ||
34 | const QString& fullVersionString() | |
35 | { | |
36 | #ifdef HG_DATE_VERSION | |
37 | if (::buildType != ReleaseBuild) { | |
38 | static const QString result = makeVersionString(::version) + "-" HG_DATE_VERSION; | |
39 | return result; | |
40 | } | |
41 | #else | |
42 | static const QString result = makeVersionString(::version); | |
43 | return result; | |
44 | #endif | |
45 | } | |
46 | ||
47 | static QString makeCommitTimeString() | |
48 | { | |
49 | QString result; | |
50 | #ifdef HG_DATE_TIME | |
51 | { | |
52 | char buffer[100]; | |
53 | constexpr time_t timestamp = HG_DATE_TIME; | |
54 | strftime (buffer, sizeof buffer, "%d %b %Y", localtime (×tamp)); | |
55 | result += buffer; | |
56 | } | |
57 | #endif | |
58 | return result; | |
59 | } | |
60 | ||
61 | const QString &commitTimeString() | |
62 | { | |
63 | static QString result = makeCommitTimeString(); | |
64 | return result; | |
65 | } |