Fossil SCM

Add the "test-date-format" command and the date_override option to tickets.

drh 2011-12-17 13:19 trunk
Commit 44f028c9f83bb190370d983307c764c38bccc5ab
2 files changed +19 +3
--- src/checkin.c
+++ src/checkin.c
@@ -586,10 +586,13 @@
586586
** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date,
587587
** print a fatal error and quit.
588588
*/
589589
char *date_in_standard_format(const char *zInputDate){
590590
char *zDate;
591
+ if( g.perm.Setup && fossil_strcmp(zInputDate,"now")==0 ){
592
+ zInputDate = PD("date_override","now");
593
+ }
591594
zDate = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%f',%Q)",
592595
zInputDate);
593596
if( zDate[0]==0 ){
594597
fossil_fatal(
595598
"unrecognized date format (%s): use \"YYYY-MM-DD HH:MM:SS.SSS\"",
@@ -596,10 +599,26 @@
596599
zInputDate
597600
);
598601
}
599602
return zDate;
600603
}
604
+
605
+/*
606
+** COMMAND: test-date-format
607
+**
608
+** Usage: %fossil test-date-format DATE-STRING...
609
+**
610
+** Convert the DATE-STRING into the standard format used in artifacts
611
+** and display the result.
612
+*/
613
+void test_date_format(void){
614
+ int i;
615
+ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
616
+ for(i=2; i<g.argc; i++){
617
+ fossil_print("%s -> %s\n", g.argv[i], date_in_standard_format(g.argv[i]));
618
+ }
619
+}
601620
602621
/*
603622
** Create a manifest.
604623
*/
605624
static void create_manifest(
606625
--- src/checkin.c
+++ src/checkin.c
@@ -586,10 +586,13 @@
586 ** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date,
587 ** print a fatal error and quit.
588 */
589 char *date_in_standard_format(const char *zInputDate){
590 char *zDate;
 
 
 
591 zDate = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%f',%Q)",
592 zInputDate);
593 if( zDate[0]==0 ){
594 fossil_fatal(
595 "unrecognized date format (%s): use \"YYYY-MM-DD HH:MM:SS.SSS\"",
@@ -596,10 +599,26 @@
596 zInputDate
597 );
598 }
599 return zDate;
600 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
602 /*
603 ** Create a manifest.
604 */
605 static void create_manifest(
606
--- src/checkin.c
+++ src/checkin.c
@@ -586,10 +586,13 @@
586 ** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date,
587 ** print a fatal error and quit.
588 */
589 char *date_in_standard_format(const char *zInputDate){
590 char *zDate;
591 if( g.perm.Setup && fossil_strcmp(zInputDate,"now")==0 ){
592 zInputDate = PD("date_override","now");
593 }
594 zDate = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%f',%Q)",
595 zInputDate);
596 if( zDate[0]==0 ){
597 fossil_fatal(
598 "unrecognized date format (%s): use \"YYYY-MM-DD HH:MM:SS.SSS\"",
@@ -596,10 +599,26 @@
599 zInputDate
600 );
601 }
602 return zDate;
603 }
604
605 /*
606 ** COMMAND: test-date-format
607 **
608 ** Usage: %fossil test-date-format DATE-STRING...
609 **
610 ** Convert the DATE-STRING into the standard format used in artifacts
611 ** and display the result.
612 */
613 void test_date_format(void){
614 int i;
615 db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
616 for(i=2; i<g.argc; i++){
617 fossil_print("%s -> %s\n", g.argv[i], date_in_standard_format(g.argv[i]));
618 }
619 }
620
621 /*
622 ** Create a manifest.
623 */
624 static void create_manifest(
625
+3
--- src/tkt.c
+++ src/tkt.c
@@ -520,10 +520,13 @@
520520
getAllTicketFields();
521521
initializeVariablesFromDb();
522522
initializeVariablesFromCGI();
523523
@ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><p>
524524
login_insert_csrf_secret();
525
+ if( P("date_override") && g.perm.Setup ){
526
+ @ <input type="hidden" name="date_override" value="%h(P("date_override"))">
527
+ }
525528
@ </p>
526529
zScript = ticket_newpage_code();
527530
Th_Store("login", g.zLogin);
528531
Th_Store("date", db_text(0, "SELECT datetime('now')"));
529532
Th_CreateCommand(g.interp, "submit_ticket", submitTicketCmd,
530533
--- src/tkt.c
+++ src/tkt.c
@@ -520,10 +520,13 @@
520 getAllTicketFields();
521 initializeVariablesFromDb();
522 initializeVariablesFromCGI();
523 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><p>
524 login_insert_csrf_secret();
 
 
 
525 @ </p>
526 zScript = ticket_newpage_code();
527 Th_Store("login", g.zLogin);
528 Th_Store("date", db_text(0, "SELECT datetime('now')"));
529 Th_CreateCommand(g.interp, "submit_ticket", submitTicketCmd,
530
--- src/tkt.c
+++ src/tkt.c
@@ -520,10 +520,13 @@
520 getAllTicketFields();
521 initializeVariablesFromDb();
522 initializeVariablesFromCGI();
523 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><p>
524 login_insert_csrf_secret();
525 if( P("date_override") && g.perm.Setup ){
526 @ <input type="hidden" name="date_override" value="%h(P("date_override"))">
527 }
528 @ </p>
529 zScript = ticket_newpage_code();
530 Th_Store("login", g.zLogin);
531 Th_Store("date", db_text(0, "SELECT datetime('now')"));
532 Th_CreateCommand(g.interp, "submit_ticket", submitTicketCmd,
533

Keyboard Shortcuts

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