src/version.cpp

changeset 272
9d52b119b3f5
parent 268
fb319526ba6c
child 273
57952c5ca59b
equal deleted inserted replaced
271:416e8c497829 272:9d52b119b3f5
15 * You should have received a copy of the GNU General Public License 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/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #include <QString> 19 #include <QString>
20 #include <QDateTime>
20 #include <time.h> 21 #include <time.h>
21 #include <hginfo.h> 22 #include <hginfo.h>
22 #include "src/version.h" 23 #include "src/version.h"
23 24
24 const char* fullVersionString() 25 #ifdef HG_ALL_TAGS
26 # define HGTEXT HG_NODE " (" HG_ALL_TAGS ")"
27 #else
28 # define HGTEXT HG_NODE
29 #endif
30
31 QString detailedVersionString()
25 { 32 {
26 if (::BUILD_TYPE != ReleaseBuild) { 33 return QStringLiteral(VERSION_STRING "-" HGTEXT)
27 return VERSION_STRING "-" HG_DATE_VERSION; 34 + " (" + revisionDateString() + ")";
28 }
29 else {
30 return VERSION_STRING;
31 }
32 } 35 }
33 36
34 static QString makeCommitTimeString() 37 QString versionString()
35 { 38 {
36 QString result; 39 #ifndef HG_VERSION_TAG
37 #ifdef HG_DATE_TIME 40 return detailedVersionString();
38 { 41 #else
39 char buffer[100]; 42 return QStringLiteral(HG_VERSION_TAG);
40 constexpr time_t timestamp = HG_DATE_TIME;
41 strftime (buffer, sizeof buffer, "%d %b %Y", localtime (&timestamp));
42 result += buffer;
43 }
44 #endif 43 #endif
45 return result;
46 } 44 }
47 45
48 const QString &commitTimeString() 46 static QString makeFullVersionString()
49 { 47 {
50 static QString result = makeCommitTimeString(); 48 QString versionstring = APPNAME " " + versionString();
51 return result; 49 return versionstring;
52 } 50 }
51
52 const QString& fullVersionString()
53 {
54 static const QString cached = makeFullVersionString();
55 return cached;
56 }
57
58 QString revisionDateString()
59 {
60 const QDateTime dt = QDateTime::fromSecsSinceEpoch(HG_DATE_TIME);
61 return dt.toString(QObject::tr("d MMMM yyyy"));
62 }

mercurial