Fossil SCM

Display compilation time in UTC or fall back to the current solution.

danield 2026-01-04 11:40 trunk
Commit f6f48d09ba025a292569cb550fbb79649544d8fb65d3f9e845dbb7a9340cef64
1 file changed +52 -2
+52 -2
--- src/main.c
+++ src/main.c
@@ -1224,10 +1224,60 @@
12241224
const char *get_version(){
12251225
static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
12261226
MANIFEST_DATE " UTC";
12271227
return version;
12281228
}
1229
+
1230
+/* Which time function (plain, _r, _s) should be used. See sqlite3.c. */
1231
+#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \
1232
+ && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
1233
+#undef HAVE_LOCALTIME_S
1234
+#define HAVE_LOCALTIME_S 1
1235
+#endif
1236
+
1237
+/*
1238
+** Return the UTC timestamp for the compilation time or fall back to
1239
+** using the information provided by the compiler as-is.
1240
+*/
1241
+static const char *get_compilation_timestamp(){
1242
+ static char zOut[24];
1243
+ int mday, mon, year;
1244
+ char zMonth[4];
1245
+ static const char *const azMonths[] =
1246
+ {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
1247
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0};
1248
+ if( 3==sscanf(__DATE__, "%3[A-Za-z] %d %d", zMonth, &mday, &year) ){
1249
+ for( mon=0; azMonths[mon]; mon++ ){
1250
+ if( !strncmp(azMonths[mon], zMonth, 3) ){
1251
+ struct tm tm_loc;
1252
+ tm_loc.tm_year = year - 1900;
1253
+ tm_loc.tm_mon = mon;
1254
+ tm_loc.tm_mday = mday;
1255
+ tm_loc.tm_isdst = -1;
1256
+ if( 3==sscanf(__TIME__, "%d:%d:%d", &tm_loc.tm_hour,
1257
+ &tm_loc.tm_min, &tm_loc.tm_sec) ){
1258
+ struct tm tm_gmt, *ptm_gmt = &tm_gmt;
1259
+ time_t tt_loc = mktime(&tm_loc);
1260
+#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S
1261
+ struct tm *pX = gmtime(&tt_loc);
1262
+ if( pX ) *ptm_gmt = *pX;
1263
+#else
1264
+#if HAVE_LOCALTIME_R
1265
+ (void)gmtime_r(&tt_loc, &tm_gmt);
1266
+#else
1267
+ (void)gmtime_s(ptm_gmt, &tt_loc);
1268
+#endif /* HAVE_LOCALTIME_R */
1269
+#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */
1270
+ if( strftime(zOut, sizeof(zOut), "%Y-%m-%d %H:%M:%S UTC", ptm_gmt) ){
1271
+ return zOut;
1272
+ }
1273
+ }
1274
+ }
1275
+ }
1276
+ }
1277
+ return __DATE__ " " __TIME__;
1278
+}
12291279
12301280
/*
12311281
** This function populates a blob with version information. It is used by
12321282
** the "version" command and "test-version" web page. It assumes the blob
12331283
** passed to it is uninitialized; otherwise, it will leak memory.
@@ -1244,12 +1294,12 @@
12441294
size_t pageSize = 0;
12451295
blob_zero(pOut);
12461296
blob_appendf(pOut, "This is fossil version %s\n", get_version());
12471297
if( eVerbose<=0 ) return;
12481298
1249
- blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
1250
- __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
1299
+ blob_appendf(pOut, "Compiled on %s using %s (%d-bit)\n",
1300
+ get_compilation_timestamp(), COMPILER_NAME, sizeof(void*)*8);
12511301
blob_appendf(pOut, "SQLite %s %.30s\n", sqlite3_libversion(),
12521302
sqlite3_sourceid());
12531303
#if defined(FOSSIL_ENABLE_SSL)
12541304
blob_appendf(pOut, "SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
12551305
#endif
12561306
--- src/main.c
+++ src/main.c
@@ -1224,10 +1224,60 @@
1224 const char *get_version(){
1225 static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
1226 MANIFEST_DATE " UTC";
1227 return version;
1228 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1229
1230 /*
1231 ** This function populates a blob with version information. It is used by
1232 ** the "version" command and "test-version" web page. It assumes the blob
1233 ** passed to it is uninitialized; otherwise, it will leak memory.
@@ -1244,12 +1294,12 @@
1244 size_t pageSize = 0;
1245 blob_zero(pOut);
1246 blob_appendf(pOut, "This is fossil version %s\n", get_version());
1247 if( eVerbose<=0 ) return;
1248
1249 blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
1250 __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
1251 blob_appendf(pOut, "SQLite %s %.30s\n", sqlite3_libversion(),
1252 sqlite3_sourceid());
1253 #if defined(FOSSIL_ENABLE_SSL)
1254 blob_appendf(pOut, "SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1255 #endif
1256
--- src/main.c
+++ src/main.c
@@ -1224,10 +1224,60 @@
1224 const char *get_version(){
1225 static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
1226 MANIFEST_DATE " UTC";
1227 return version;
1228 }
1229
1230 /* Which time function (plain, _r, _s) should be used. See sqlite3.c. */
1231 #if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \
1232 && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
1233 #undef HAVE_LOCALTIME_S
1234 #define HAVE_LOCALTIME_S 1
1235 #endif
1236
1237 /*
1238 ** Return the UTC timestamp for the compilation time or fall back to
1239 ** using the information provided by the compiler as-is.
1240 */
1241 static const char *get_compilation_timestamp(){
1242 static char zOut[24];
1243 int mday, mon, year;
1244 char zMonth[4];
1245 static const char *const azMonths[] =
1246 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
1247 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0};
1248 if( 3==sscanf(__DATE__, "%3[A-Za-z] %d %d", zMonth, &mday, &year) ){
1249 for( mon=0; azMonths[mon]; mon++ ){
1250 if( !strncmp(azMonths[mon], zMonth, 3) ){
1251 struct tm tm_loc;
1252 tm_loc.tm_year = year - 1900;
1253 tm_loc.tm_mon = mon;
1254 tm_loc.tm_mday = mday;
1255 tm_loc.tm_isdst = -1;
1256 if( 3==sscanf(__TIME__, "%d:%d:%d", &tm_loc.tm_hour,
1257 &tm_loc.tm_min, &tm_loc.tm_sec) ){
1258 struct tm tm_gmt, *ptm_gmt = &tm_gmt;
1259 time_t tt_loc = mktime(&tm_loc);
1260 #if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S
1261 struct tm *pX = gmtime(&tt_loc);
1262 if( pX ) *ptm_gmt = *pX;
1263 #else
1264 #if HAVE_LOCALTIME_R
1265 (void)gmtime_r(&tt_loc, &tm_gmt);
1266 #else
1267 (void)gmtime_s(ptm_gmt, &tt_loc);
1268 #endif /* HAVE_LOCALTIME_R */
1269 #endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */
1270 if( strftime(zOut, sizeof(zOut), "%Y-%m-%d %H:%M:%S UTC", ptm_gmt) ){
1271 return zOut;
1272 }
1273 }
1274 }
1275 }
1276 }
1277 return __DATE__ " " __TIME__;
1278 }
1279
1280 /*
1281 ** This function populates a blob with version information. It is used by
1282 ** the "version" command and "test-version" web page. It assumes the blob
1283 ** passed to it is uninitialized; otherwise, it will leak memory.
@@ -1244,12 +1294,12 @@
1294 size_t pageSize = 0;
1295 blob_zero(pOut);
1296 blob_appendf(pOut, "This is fossil version %s\n", get_version());
1297 if( eVerbose<=0 ) return;
1298
1299 blob_appendf(pOut, "Compiled on %s using %s (%d-bit)\n",
1300 get_compilation_timestamp(), COMPILER_NAME, sizeof(void*)*8);
1301 blob_appendf(pOut, "SQLite %s %.30s\n", sqlite3_libversion(),
1302 sqlite3_sourceid());
1303 #if defined(FOSSIL_ENABLE_SSL)
1304 blob_appendf(pOut, "SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1305 #endif
1306

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button