Fossil SCM

(experimental) Allow not only --utc or --localtime to be specified, but any timezone (minutes from UTC = -999...999)

jan.nijtmans 2014-01-29 22:51 UTC trunk
Commit c3e3ceb9b645ffeed56f02eccee437b282803073
2 files changed +11 -3 +13 -7
+11 -3
--- src/main.c
+++ src/main.c
@@ -161,11 +161,12 @@
161161
Th_Interp *interp; /* The TH1 interpreter */
162162
char *th1Setup; /* The TH1 post-creation setup script, if any */
163163
FILE *httpIn; /* Accept HTTP input from here */
164164
FILE *httpOut; /* Send HTTP output here */
165165
int xlinkClusterOnly; /* Set when cloning. Only process clusters */
166
- int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
166
+ int fTimeFormat; /* 1000 for UTC. -1000 for localtime. 0 not yet selected */
167
+ /* -999...999 = minutes difference from UTC */
167168
int *aCommitFile; /* Array of files to be committed */
168169
int markPrivate; /* All new artifacts are private if true */
169170
int clockSkewSeen; /* True if clocks on client and server out of sync */
170171
int wikiFlags; /* Wiki conversion flags applied to %w and %W */
171172
char isHTTP; /* True if server/CGI modes, else assume CLI. */
@@ -637,10 +638,11 @@
637638
"another flag and is treated as such. --args FILENAME may be used\n"
638639
"in conjunction with any other flags.\n");
639640
fossil_exit(1);
640641
}else{
641642
const char *zChdir = find_option("chdir",0,1);
643
+ const char *zTimezone = find_option("tz",0,1);
642644
g.isHTTP = 0;
643645
g.fQuiet = find_option("quiet", 0, 0)!=0;
644646
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
645647
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
646648
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
@@ -651,12 +653,18 @@
651653
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
652654
g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
653655
g.zLogin = find_option("user", "U", 1);
654656
g.zSSLIdentity = find_option("ssl-identity", 0, 1);
655657
g.zErrlog = find_option("errorlog", 0, 1);
656
- if( find_option("utc",0,0) ) g.fTimeFormat = 1;
657
- if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
658
+ if( zTimezone ){
659
+ int tz = (int)strtol(zTimezone, 0, 0);
660
+ if( tz<-999 || tz >999 ){
661
+ fossil_fatal("wrong timezone format %s", zTimezone);
662
+ }
663
+ g.fTimeFormat = tz ? tz : 1000;
664
+ }else if( find_option("utc",0,0) ) g.fTimeFormat = 1000;
665
+ else if( find_option("localtime",0,0) ) g.fTimeFormat = -1000;
658666
if( zChdir && file_chdir(zChdir, 0) ){
659667
fossil_fatal("unable to change directories to %s", zChdir);
660668
}
661669
if( find_option("help",0,0)!=0 ){
662670
/* --help anywhere on the command line is translated into
663671
--- src/main.c
+++ src/main.c
@@ -161,11 +161,12 @@
161 Th_Interp *interp; /* The TH1 interpreter */
162 char *th1Setup; /* The TH1 post-creation setup script, if any */
163 FILE *httpIn; /* Accept HTTP input from here */
164 FILE *httpOut; /* Send HTTP output here */
165 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
166 int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
 
167 int *aCommitFile; /* Array of files to be committed */
168 int markPrivate; /* All new artifacts are private if true */
169 int clockSkewSeen; /* True if clocks on client and server out of sync */
170 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
171 char isHTTP; /* True if server/CGI modes, else assume CLI. */
@@ -637,10 +638,11 @@
637 "another flag and is treated as such. --args FILENAME may be used\n"
638 "in conjunction with any other flags.\n");
639 fossil_exit(1);
640 }else{
641 const char *zChdir = find_option("chdir",0,1);
 
642 g.isHTTP = 0;
643 g.fQuiet = find_option("quiet", 0, 0)!=0;
644 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
645 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
646 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
@@ -651,12 +653,18 @@
651 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
652 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
653 g.zLogin = find_option("user", "U", 1);
654 g.zSSLIdentity = find_option("ssl-identity", 0, 1);
655 g.zErrlog = find_option("errorlog", 0, 1);
656 if( find_option("utc",0,0) ) g.fTimeFormat = 1;
657 if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
 
 
 
 
 
 
658 if( zChdir && file_chdir(zChdir, 0) ){
659 fossil_fatal("unable to change directories to %s", zChdir);
660 }
661 if( find_option("help",0,0)!=0 ){
662 /* --help anywhere on the command line is translated into
663
--- src/main.c
+++ src/main.c
@@ -161,11 +161,12 @@
161 Th_Interp *interp; /* The TH1 interpreter */
162 char *th1Setup; /* The TH1 post-creation setup script, if any */
163 FILE *httpIn; /* Accept HTTP input from here */
164 FILE *httpOut; /* Send HTTP output here */
165 int xlinkClusterOnly; /* Set when cloning. Only process clusters */
166 int fTimeFormat; /* 1000 for UTC. -1000 for localtime. 0 not yet selected */
167 /* -999...999 = minutes difference from UTC */
168 int *aCommitFile; /* Array of files to be committed */
169 int markPrivate; /* All new artifacts are private if true */
170 int clockSkewSeen; /* True if clocks on client and server out of sync */
171 int wikiFlags; /* Wiki conversion flags applied to %w and %W */
172 char isHTTP; /* True if server/CGI modes, else assume CLI. */
@@ -637,10 +638,11 @@
638 "another flag and is treated as such. --args FILENAME may be used\n"
639 "in conjunction with any other flags.\n");
640 fossil_exit(1);
641 }else{
642 const char *zChdir = find_option("chdir",0,1);
643 const char *zTimezone = find_option("tz",0,1);
644 g.isHTTP = 0;
645 g.fQuiet = find_option("quiet", 0, 0)!=0;
646 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
647 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
648 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
@@ -651,12 +653,18 @@
653 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
654 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
655 g.zLogin = find_option("user", "U", 1);
656 g.zSSLIdentity = find_option("ssl-identity", 0, 1);
657 g.zErrlog = find_option("errorlog", 0, 1);
658 if( zTimezone ){
659 int tz = (int)strtol(zTimezone, 0, 0);
660 if( tz<-999 || tz >999 ){
661 fossil_fatal("wrong timezone format %s", zTimezone);
662 }
663 g.fTimeFormat = tz ? tz : 1000;
664 }else if( find_option("utc",0,0) ) g.fTimeFormat = 1000;
665 else if( find_option("localtime",0,0) ) g.fTimeFormat = -1000;
666 if( zChdir && file_chdir(zChdir, 0) ){
667 fossil_fatal("unable to change directories to %s", zChdir);
668 }
669 if( find_option("help",0,0)!=0 ){
670 /* --help anywhere on the command line is translated into
671
+13 -7
--- src/timeline.c
+++ src/timeline.c
@@ -1885,29 +1885,35 @@
18851885
print_timeline(&q, n, width, verboseFlag);
18861886
db_finalize(&q);
18871887
}
18881888
18891889
/*
1890
-** Return one of two things:
1890
+** Return one of three forms:
1891
+**
1892
+** ",'localtime'" when (server) localtime is desired
18911893
**
1892
-** ",'localtime'" if the timeline-utc property is set to 0.
1894
+** "" when UTC is desired
18931895
**
1894
-** "" (empty string) otherwise.
1896
+** ",'??? minutes'" otherwise
18951897
*/
18961898
const char *timeline_utc(){
1899
+ static char buf[16] = ""; /* only initialized once. */
18971900
if( g.fTimeFormat==0 ){
18981901
if( db_get_int("timeline-utc", 1) ){
1899
- g.fTimeFormat = 1;
1902
+ g.fTimeFormat = 1000;
19001903
}else{
1901
- g.fTimeFormat = 2;
1904
+ g.fTimeFormat = -1000;
19021905
}
19031906
}
1904
- if( g.fTimeFormat==1 ){
1907
+ if( g.fTimeFormat>999 )
19051908
return "";
1906
- }else{
1909
+ if( g.fTimeFormat<-999 )
19071910
return ",'localtime'";
1911
+ if( !buf[0] ){
1912
+ sprintf(buf, ",'%d minutes'", g.fTimeFormat);
19081913
}
1914
+ return buf;
19091915
}
19101916
19111917
19121918
/*
19131919
** COMMAND: test-timewarp-list
19141920
--- src/timeline.c
+++ src/timeline.c
@@ -1885,29 +1885,35 @@
1885 print_timeline(&q, n, width, verboseFlag);
1886 db_finalize(&q);
1887 }
1888
1889 /*
1890 ** Return one of two things:
 
 
1891 **
1892 ** ",'localtime'" if the timeline-utc property is set to 0.
1893 **
1894 ** "" (empty string) otherwise.
1895 */
1896 const char *timeline_utc(){
 
1897 if( g.fTimeFormat==0 ){
1898 if( db_get_int("timeline-utc", 1) ){
1899 g.fTimeFormat = 1;
1900 }else{
1901 g.fTimeFormat = 2;
1902 }
1903 }
1904 if( g.fTimeFormat==1 ){
1905 return "";
1906 }else{
1907 return ",'localtime'";
 
 
1908 }
 
1909 }
1910
1911
1912 /*
1913 ** COMMAND: test-timewarp-list
1914
--- src/timeline.c
+++ src/timeline.c
@@ -1885,29 +1885,35 @@
1885 print_timeline(&q, n, width, verboseFlag);
1886 db_finalize(&q);
1887 }
1888
1889 /*
1890 ** Return one of three forms:
1891 **
1892 ** ",'localtime'" when (server) localtime is desired
1893 **
1894 ** "" when UTC is desired
1895 **
1896 ** ",'??? minutes'" otherwise
1897 */
1898 const char *timeline_utc(){
1899 static char buf[16] = ""; /* only initialized once. */
1900 if( g.fTimeFormat==0 ){
1901 if( db_get_int("timeline-utc", 1) ){
1902 g.fTimeFormat = 1000;
1903 }else{
1904 g.fTimeFormat = -1000;
1905 }
1906 }
1907 if( g.fTimeFormat>999 )
1908 return "";
1909 if( g.fTimeFormat<-999 )
1910 return ",'localtime'";
1911 if( !buf[0] ){
1912 sprintf(buf, ",'%d minutes'", g.fTimeFormat);
1913 }
1914 return buf;
1915 }
1916
1917
1918 /*
1919 ** COMMAND: test-timewarp-list
1920

Keyboard Shortcuts

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