Fossil SCM
Add the "test-date-format" command and the date_override option to tickets.
Commit
44f028c9f83bb190370d983307c764c38bccc5ab
Parent
339a0f49d21e02a…
2 files changed
+19
+3
+19
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -586,10 +586,13 @@ | ||
| 586 | 586 | ** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date, |
| 587 | 587 | ** print a fatal error and quit. |
| 588 | 588 | */ |
| 589 | 589 | char *date_in_standard_format(const char *zInputDate){ |
| 590 | 590 | char *zDate; |
| 591 | + if( g.perm.Setup && fossil_strcmp(zInputDate,"now")==0 ){ | |
| 592 | + zInputDate = PD("date_override","now"); | |
| 593 | + } | |
| 591 | 594 | zDate = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%f',%Q)", |
| 592 | 595 | zInputDate); |
| 593 | 596 | if( zDate[0]==0 ){ |
| 594 | 597 | fossil_fatal( |
| 595 | 598 | "unrecognized date format (%s): use \"YYYY-MM-DD HH:MM:SS.SSS\"", |
| @@ -596,10 +599,26 @@ | ||
| 596 | 599 | zInputDate |
| 597 | 600 | ); |
| 598 | 601 | } |
| 599 | 602 | return zDate; |
| 600 | 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 | +} | |
| 601 | 620 | |
| 602 | 621 | /* |
| 603 | 622 | ** Create a manifest. |
| 604 | 623 | */ |
| 605 | 624 | static void create_manifest( |
| 606 | 625 |
| --- 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 @@ | ||
| 520 | 520 | getAllTicketFields(); |
| 521 | 521 | initializeVariablesFromDb(); |
| 522 | 522 | initializeVariablesFromCGI(); |
| 523 | 523 | @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><p> |
| 524 | 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 | + } | |
| 525 | 528 | @ </p> |
| 526 | 529 | zScript = ticket_newpage_code(); |
| 527 | 530 | Th_Store("login", g.zLogin); |
| 528 | 531 | Th_Store("date", db_text(0, "SELECT datetime('now')")); |
| 529 | 532 | Th_CreateCommand(g.interp, "submit_ticket", submitTicketCmd, |
| 530 | 533 |
| --- 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 |