Fossil SCM

Document the timeline-utc setting. Provide C-language interfaces to access that setting consistently.

drh 2024-12-26 11:19 trunk
Commit b1bb31e838138c8ee768abd63c149734abf8f9907e7ee6235d5d1bfaec655072
1 file changed +42 -16
+42 -16
--- src/db.c
+++ src/db.c
@@ -1349,10 +1349,50 @@
13491349
sqlite3_result_int64(context, rid);
13501350
}
13511351
}
13521352
}
13531353
1354
+
1355
+/*
1356
+** SETTING: timeline-utc boolean default=on
1357
+**
1358
+** If the timeline-utc setting is true, then Fossil tries to understand
1359
+** and display all time values using UTC. If this setting is false, Fossil
1360
+** tries to understand and display time values using the local timezone.
1361
+**
1362
+** The word "timeline" in the name of this setting is historical.
1363
+** This setting applies to all user interfaces of Fossil,
1364
+** not just the timeline.
1365
+**
1366
+** Note that when accessing Fossil using the web interface, the localtime
1367
+** used is the localtime on the server, not on the client.
1368
+*/
1369
+/*
1370
+** Return true if Fossil is set to display times as UTC. Return false
1371
+** if it wants to display times using the local timezone.
1372
+**
1373
+** False is returned if display is set to localtime even if the localtime
1374
+** happens to be the same as UTC.
1375
+*/
1376
+int fossil_ui_utctime(void){
1377
+ if( g.fTimeFormat==0 ){
1378
+ if( db_get_int("timeline-utc", 1) ){
1379
+ g.fTimeFormat = 1; /* UTC */
1380
+ }else{
1381
+ g.fTimeFormat = 2; /* Localtime */
1382
+ }
1383
+ }
1384
+ return g.fTimeFormat==1;
1385
+}
1386
+
1387
+/*
1388
+** Return true if Fossil is set to display times using the local timezone.
1389
+*/
1390
+int fossil_use_localtime(void){
1391
+ return fossil_ui_utctime()==0;
1392
+}
1393
+
13541394
/*
13551395
** The toLocal() SQL function returns a string that is an argument to a
13561396
** date/time function that is appropriate for modifying the time for display.
13571397
** If UTC time display is selected, no modification occurs. If local time
13581398
** display is selected, the time is adjusted appropriately.
@@ -1364,18 +1404,11 @@
13641404
void db_tolocal_function(
13651405
sqlite3_context *context,
13661406
int argc,
13671407
sqlite3_value **argv
13681408
){
1369
- if( g.fTimeFormat==0 ){
1370
- if( db_get_int("timeline-utc", 1) ){
1371
- g.fTimeFormat = 1;
1372
- }else{
1373
- g.fTimeFormat = 2;
1374
- }
1375
- }
1376
- if( g.fTimeFormat==1 ){
1409
+ if( fossil_ui_utctime() ){
13771410
sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
13781411
}else{
13791412
sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
13801413
}
13811414
}
@@ -1393,18 +1426,11 @@
13931426
void db_fromlocal_function(
13941427
sqlite3_context *context,
13951428
int argc,
13961429
sqlite3_value **argv
13971430
){
1398
- if( g.fTimeFormat==0 ){
1399
- if( db_get_int("timeline-utc", 1) ){
1400
- g.fTimeFormat = 1;
1401
- }else{
1402
- g.fTimeFormat = 2;
1403
- }
1404
- }
1405
- if( g.fTimeFormat==1 ){
1431
+ if( fossil_ui_utctime() ){
14061432
sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
14071433
}else{
14081434
sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
14091435
}
14101436
}
14111437
--- src/db.c
+++ src/db.c
@@ -1349,10 +1349,50 @@
1349 sqlite3_result_int64(context, rid);
1350 }
1351 }
1352 }
1353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1354 /*
1355 ** The toLocal() SQL function returns a string that is an argument to a
1356 ** date/time function that is appropriate for modifying the time for display.
1357 ** If UTC time display is selected, no modification occurs. If local time
1358 ** display is selected, the time is adjusted appropriately.
@@ -1364,18 +1404,11 @@
1364 void db_tolocal_function(
1365 sqlite3_context *context,
1366 int argc,
1367 sqlite3_value **argv
1368 ){
1369 if( g.fTimeFormat==0 ){
1370 if( db_get_int("timeline-utc", 1) ){
1371 g.fTimeFormat = 1;
1372 }else{
1373 g.fTimeFormat = 2;
1374 }
1375 }
1376 if( g.fTimeFormat==1 ){
1377 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1378 }else{
1379 sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
1380 }
1381 }
@@ -1393,18 +1426,11 @@
1393 void db_fromlocal_function(
1394 sqlite3_context *context,
1395 int argc,
1396 sqlite3_value **argv
1397 ){
1398 if( g.fTimeFormat==0 ){
1399 if( db_get_int("timeline-utc", 1) ){
1400 g.fTimeFormat = 1;
1401 }else{
1402 g.fTimeFormat = 2;
1403 }
1404 }
1405 if( g.fTimeFormat==1 ){
1406 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1407 }else{
1408 sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
1409 }
1410 }
1411
--- src/db.c
+++ src/db.c
@@ -1349,10 +1349,50 @@
1349 sqlite3_result_int64(context, rid);
1350 }
1351 }
1352 }
1353
1354
1355 /*
1356 ** SETTING: timeline-utc boolean default=on
1357 **
1358 ** If the timeline-utc setting is true, then Fossil tries to understand
1359 ** and display all time values using UTC. If this setting is false, Fossil
1360 ** tries to understand and display time values using the local timezone.
1361 **
1362 ** The word "timeline" in the name of this setting is historical.
1363 ** This setting applies to all user interfaces of Fossil,
1364 ** not just the timeline.
1365 **
1366 ** Note that when accessing Fossil using the web interface, the localtime
1367 ** used is the localtime on the server, not on the client.
1368 */
1369 /*
1370 ** Return true if Fossil is set to display times as UTC. Return false
1371 ** if it wants to display times using the local timezone.
1372 **
1373 ** False is returned if display is set to localtime even if the localtime
1374 ** happens to be the same as UTC.
1375 */
1376 int fossil_ui_utctime(void){
1377 if( g.fTimeFormat==0 ){
1378 if( db_get_int("timeline-utc", 1) ){
1379 g.fTimeFormat = 1; /* UTC */
1380 }else{
1381 g.fTimeFormat = 2; /* Localtime */
1382 }
1383 }
1384 return g.fTimeFormat==1;
1385 }
1386
1387 /*
1388 ** Return true if Fossil is set to display times using the local timezone.
1389 */
1390 int fossil_use_localtime(void){
1391 return fossil_ui_utctime()==0;
1392 }
1393
1394 /*
1395 ** The toLocal() SQL function returns a string that is an argument to a
1396 ** date/time function that is appropriate for modifying the time for display.
1397 ** If UTC time display is selected, no modification occurs. If local time
1398 ** display is selected, the time is adjusted appropriately.
@@ -1364,18 +1404,11 @@
1404 void db_tolocal_function(
1405 sqlite3_context *context,
1406 int argc,
1407 sqlite3_value **argv
1408 ){
1409 if( fossil_ui_utctime() ){
 
 
 
 
 
 
 
1410 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1411 }else{
1412 sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
1413 }
1414 }
@@ -1393,18 +1426,11 @@
1426 void db_fromlocal_function(
1427 sqlite3_context *context,
1428 int argc,
1429 sqlite3_value **argv
1430 ){
1431 if( fossil_ui_utctime() ){
 
 
 
 
 
 
 
1432 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1433 }else{
1434 sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
1435 }
1436 }
1437

Keyboard Shortcuts

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