Fossil SCM
Fix off-by-one error in cgi_iso8601_datestamp(). Add the test-date command for testing.
Commit
6389c999cee8e07c6af9788e75277d75c775b9b95ba299ef3c6bb379fa28e5b1
Parent
f3f3c1db6f913a7…
1 file changed
+11
-1
+11
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -2318,14 +2318,24 @@ | ||
| 2318 | 2318 | pTm = gmtime(&now); |
| 2319 | 2319 | if( pTm==0 ){ |
| 2320 | 2320 | return mprintf(""); |
| 2321 | 2321 | }else{ |
| 2322 | 2322 | return mprintf("%04d-%02d-%02d %02d:%02d:%02d", |
| 2323 | - pTm->tm_year+1900, pTm->tm_mon, pTm->tm_mday, | |
| 2323 | + pTm->tm_year+1900, pTm->tm_mon+1, pTm->tm_mday, | |
| 2324 | 2324 | pTm->tm_hour, pTm->tm_min, pTm->tm_sec); |
| 2325 | 2325 | } |
| 2326 | 2326 | } |
| 2327 | + | |
| 2328 | +/* | |
| 2329 | +** COMMAND: test-date | |
| 2330 | +** | |
| 2331 | +** Show the current date and time in both RFC822 and ISO8601. | |
| 2332 | +*/ | |
| 2333 | +void test_date(void){ | |
| 2334 | + fossil_print("%z = ", cgi_iso8601_datestamp()); | |
| 2335 | + fossil_print("%z\n", cgi_rfc822_datestamp(time(0))); | |
| 2336 | +} | |
| 2327 | 2337 | |
| 2328 | 2338 | /* |
| 2329 | 2339 | ** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return |
| 2330 | 2340 | ** a Unix epoch time. <= zero is returned on failure. |
| 2331 | 2341 | ** |
| 2332 | 2342 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2318,14 +2318,24 @@ | |
| 2318 | pTm = gmtime(&now); |
| 2319 | if( pTm==0 ){ |
| 2320 | return mprintf(""); |
| 2321 | }else{ |
| 2322 | return mprintf("%04d-%02d-%02d %02d:%02d:%02d", |
| 2323 | pTm->tm_year+1900, pTm->tm_mon, pTm->tm_mday, |
| 2324 | pTm->tm_hour, pTm->tm_min, pTm->tm_sec); |
| 2325 | } |
| 2326 | } |
| 2327 | |
| 2328 | /* |
| 2329 | ** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return |
| 2330 | ** a Unix epoch time. <= zero is returned on failure. |
| 2331 | ** |
| 2332 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2318,14 +2318,24 @@ | |
| 2318 | pTm = gmtime(&now); |
| 2319 | if( pTm==0 ){ |
| 2320 | return mprintf(""); |
| 2321 | }else{ |
| 2322 | return mprintf("%04d-%02d-%02d %02d:%02d:%02d", |
| 2323 | pTm->tm_year+1900, pTm->tm_mon+1, pTm->tm_mday, |
| 2324 | pTm->tm_hour, pTm->tm_min, pTm->tm_sec); |
| 2325 | } |
| 2326 | } |
| 2327 | |
| 2328 | /* |
| 2329 | ** COMMAND: test-date |
| 2330 | ** |
| 2331 | ** Show the current date and time in both RFC822 and ISO8601. |
| 2332 | */ |
| 2333 | void test_date(void){ |
| 2334 | fossil_print("%z = ", cgi_iso8601_datestamp()); |
| 2335 | fossil_print("%z\n", cgi_rfc822_datestamp(time(0))); |
| 2336 | } |
| 2337 | |
| 2338 | /* |
| 2339 | ** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return |
| 2340 | ** a Unix epoch time. <= zero is returned on failure. |
| 2341 | ** |
| 2342 |