Fossil SCM

Fix off-by-one error in cgi_iso8601_datestamp(). Add the test-date command for testing.

drh 2021-10-27 13:01 trunk
Commit 6389c999cee8e07c6af9788e75277d75c775b9b95ba299ef3c6bb379fa28e5b1
1 file changed +11 -1
+11 -1
--- src/cgi.c
+++ src/cgi.c
@@ -2318,14 +2318,24 @@
23182318
pTm = gmtime(&now);
23192319
if( pTm==0 ){
23202320
return mprintf("");
23212321
}else{
23222322
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,
23242324
pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
23252325
}
23262326
}
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
+}
23272337
23282338
/*
23292339
** Parse an RFC822-formatted timestamp as we'd expect from HTTP and return
23302340
** a Unix epoch time. <= zero is returned on failure.
23312341
**
23322342
--- 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

Keyboard Shortcuts

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