Fossil SCM
Fix the yw= query parameter of /timeline so that it honor the Z zulu-time mark.
Commit
e9c68906107bc43267e6d4fc034838cab92569526e70904e9084b7f81443fecb
Parent
376170abff9757f…
2 files changed
+4
-4
+38
-27
+4
-4
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -290,12 +290,12 @@ | ||
| 290 | 290 | nEventsPerYear += nCount; |
| 291 | 291 | @<tr class='row%d(rowClass)'> |
| 292 | 292 | @ <td> |
| 293 | 293 | if(includeMonth){ |
| 294 | 294 | cgi_printf("<a href='%R/timeline?" |
| 295 | - "ym=%t&n=%d&y=%s", | |
| 296 | - zTimeframe, nCount, | |
| 295 | + "ym=%t&y=%s", | |
| 296 | + zTimeframe, | |
| 297 | 297 | statsReportTimelineYFlag ); |
| 298 | 298 | /* Reminder: n=nCount is not actually correct for bymonth unless |
| 299 | 299 | that was the only user who caused events. |
| 300 | 300 | */ |
| 301 | 301 | if( zUserName ){ |
| @@ -731,12 +731,12 @@ | ||
| 731 | 731 | ? (int)(100 * nCount / nMaxEvents) |
| 732 | 732 | : 0; |
| 733 | 733 | if(!nSize) nSize = 1; |
| 734 | 734 | total += nCount; |
| 735 | 735 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 736 | - cgi_printf("<td><a href='%R/timeline?yw=%t-%s&n=%d&y=%s", | |
| 737 | - zYear, zWeek, nCount, | |
| 736 | + cgi_printf("<td><a href='%R/timeline?yw=%t%s&y=%s", | |
| 737 | + zYear, zWeek, | |
| 738 | 738 | statsReportTimelineYFlag); |
| 739 | 739 | if( zUserName ){ |
| 740 | 740 | cgi_printf("&u=%t",zUserName); |
| 741 | 741 | } |
| 742 | 742 | cgi_printf("'>%s</a></td>",zWeek); |
| 743 | 743 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -290,12 +290,12 @@ | |
| 290 | nEventsPerYear += nCount; |
| 291 | @<tr class='row%d(rowClass)'> |
| 292 | @ <td> |
| 293 | if(includeMonth){ |
| 294 | cgi_printf("<a href='%R/timeline?" |
| 295 | "ym=%t&n=%d&y=%s", |
| 296 | zTimeframe, nCount, |
| 297 | statsReportTimelineYFlag ); |
| 298 | /* Reminder: n=nCount is not actually correct for bymonth unless |
| 299 | that was the only user who caused events. |
| 300 | */ |
| 301 | if( zUserName ){ |
| @@ -731,12 +731,12 @@ | |
| 731 | ? (int)(100 * nCount / nMaxEvents) |
| 732 | : 0; |
| 733 | if(!nSize) nSize = 1; |
| 734 | total += nCount; |
| 735 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 736 | cgi_printf("<td><a href='%R/timeline?yw=%t-%s&n=%d&y=%s", |
| 737 | zYear, zWeek, nCount, |
| 738 | statsReportTimelineYFlag); |
| 739 | if( zUserName ){ |
| 740 | cgi_printf("&u=%t",zUserName); |
| 741 | } |
| 742 | cgi_printf("'>%s</a></td>",zWeek); |
| 743 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -290,12 +290,12 @@ | |
| 290 | nEventsPerYear += nCount; |
| 291 | @<tr class='row%d(rowClass)'> |
| 292 | @ <td> |
| 293 | if(includeMonth){ |
| 294 | cgi_printf("<a href='%R/timeline?" |
| 295 | "ym=%t&y=%s", |
| 296 | zTimeframe, |
| 297 | statsReportTimelineYFlag ); |
| 298 | /* Reminder: n=nCount is not actually correct for bymonth unless |
| 299 | that was the only user who caused events. |
| 300 | */ |
| 301 | if( zUserName ){ |
| @@ -731,12 +731,12 @@ | |
| 731 | ? (int)(100 * nCount / nMaxEvents) |
| 732 | : 0; |
| 733 | if(!nSize) nSize = 1; |
| 734 | total += nCount; |
| 735 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 736 | cgi_printf("<td><a href='%R/timeline?yw=%t%s&y=%s", |
| 737 | zYear, zWeek, |
| 738 | statsReportTimelineYFlag); |
| 739 | if( zUserName ){ |
| 740 | cgi_printf("&u=%t",zUserName); |
| 741 | } |
| 742 | cgi_printf("'>%s</a></td>",zWeek); |
| 743 |
+38
-27
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -2379,13 +2379,11 @@ | ||
| 2379 | 2379 | if( zYearMonth ){ |
| 2380 | 2380 | char *zNext; |
| 2381 | 2381 | int bZulu = 0; |
| 2382 | 2382 | const char *zTZMod; |
| 2383 | 2383 | zYearMonth = timeline_expand_datetime(zYearMonth, &bZulu); |
| 2384 | - if( strlen(zYearMonth)>7 ){ | |
| 2385 | - zYearMonth = mprintf("%.7s", zYearMonth); | |
| 2386 | - } | |
| 2384 | + zYearMonth = mprintf("%.7s", zYearMonth); | |
| 2387 | 2385 | if( db_int(0,"SELECT julianday('%q-01') IS NULL", zYearMonth) ){ |
| 2388 | 2386 | zYearMonth = db_text(0, "SELECT strftime('%%Y-%%m','now');"); |
| 2389 | 2387 | } |
| 2390 | 2388 | zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00"; |
| 2391 | 2389 | if( db_int(0, |
| @@ -2415,14 +2413,17 @@ | ||
| 2415 | 2413 | blob_append_sql(&cond, |
| 2416 | 2414 | " AND event.mtime>=julianday('%q-01',%Q)" |
| 2417 | 2415 | " AND event.mtime<julianday('%q-01',%Q,'+1 month')\n", |
| 2418 | 2416 | zYearMonth, zTZMod, zYearMonth, zTZMod); |
| 2419 | 2417 | nEntry = -1; |
| 2418 | + /* Adjust the zYearMonth for the title */ | |
| 2419 | + zYearMonth = mprintf("%z-01%s", zYearMonth, &"Z"[!bZulu]); | |
| 2420 | 2420 | } |
| 2421 | 2421 | else if( zYearWeek ){ |
| 2422 | 2422 | char *z, *zNext; |
| 2423 | 2423 | int bZulu = 0; |
| 2424 | + const char *zTZMod; | |
| 2424 | 2425 | zYearWeek = timeline_expand_datetime(zYearWeek, &bZulu); |
| 2425 | 2426 | z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek); |
| 2426 | 2427 | if( z && z[0] ){ |
| 2427 | 2428 | zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')", |
| 2428 | 2429 | zYearWeek); |
| @@ -2440,33 +2441,43 @@ | ||
| 2440 | 2441 | "SELECT date('now','-6 days','weekday 1');"); |
| 2441 | 2442 | zYearWeek = db_text(0, |
| 2442 | 2443 | "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')"); |
| 2443 | 2444 | } |
| 2444 | 2445 | } |
| 2445 | - zNext = db_text(0, "SELECT date(%Q,'+7 day');", zYearWeekStart); | |
| 2446 | - if( db_int(0, | |
| 2447 | - "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" | |
| 2448 | - " WHERE blob.rid=event.objid AND mtime>=julianday(%Q)%s)", | |
| 2449 | - zNext, blob_sql_text(&cond)) | |
| 2450 | - ){ | |
| 2451 | - zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); | |
| 2452 | - zNewerButtonLabel = "Following week"; | |
| 2453 | - } | |
| 2454 | - fossil_free(zNext); | |
| 2455 | - zNext = db_text(0, "SELECT date(%Q,'-7 days');", zYearWeekStart); | |
| 2456 | - if( db_int(0, | |
| 2457 | - "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" | |
| 2458 | - " WHERE blob.rid=event.objid AND mtime<julianday(%Q)%s)", | |
| 2459 | - zYearWeekStart, blob_sql_text(&cond)) | |
| 2460 | - ){ | |
| 2461 | - zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); | |
| 2462 | - zOlderButtonLabel = "Previous week"; | |
| 2463 | - } | |
| 2464 | - fossil_free(zNext); | |
| 2465 | - blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ", | |
| 2466 | - zYearWeek); | |
| 2467 | - nEntry = -1; | |
| 2446 | + zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00"; | |
| 2447 | + if( db_int(0, | |
| 2448 | + "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" | |
| 2449 | + " WHERE blob.rid=event.objid" | |
| 2450 | + " AND mtime>=julianday(%Q,%Q)%s)", | |
| 2451 | + zYearWeekStart, zTZMod, blob_sql_text(&cond)) | |
| 2452 | + ){ | |
| 2453 | + zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'+7 day');", | |
| 2454 | + &"Z"[!bZulu], zYearWeekStart); | |
| 2455 | + zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); | |
| 2456 | + zNewerButtonLabel = "Following week"; | |
| 2457 | + fossil_free(zNext); | |
| 2458 | + } | |
| 2459 | + if( db_int(0, | |
| 2460 | + "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" | |
| 2461 | + " WHERE blob.rid=event.objid" | |
| 2462 | + " AND mtime<julianday(%Q,%Q)%s)", | |
| 2463 | + zYearWeekStart, zTZMod, blob_sql_text(&cond)) | |
| 2464 | + ){ | |
| 2465 | + zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'-7 days');", | |
| 2466 | + &"Z"[!bZulu], zYearWeekStart); | |
| 2467 | + zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); | |
| 2468 | + zOlderButtonLabel = "Previous week"; | |
| 2469 | + fossil_free(zNext); | |
| 2470 | + } | |
| 2471 | + blob_append_sql(&cond, | |
| 2472 | + " AND event.mtime>=julianday(%Q,%Q)" | |
| 2473 | + " AND event.mtime<julianday(%Q,%Q,'+7 days')\n", | |
| 2474 | + zYearWeekStart, zTZMod, zYearWeekStart, zTZMod); | |
| 2475 | + nEntry = -1; | |
| 2476 | + if( fossil_ui_localtime() && bZulu ){ | |
| 2477 | + zYearWeekStart = mprintf("%zZ", zYearWeekStart); | |
| 2478 | + } | |
| 2468 | 2479 | } |
| 2469 | 2480 | else if( zDay ){ |
| 2470 | 2481 | char *zNext; |
| 2471 | 2482 | int bZulu = 0; |
| 2472 | 2483 | const char *zTZMod; |
| @@ -2752,11 +2763,11 @@ | ||
| 2752 | 2763 | db_multi_exec("%s", blob_sql_text(&sql)); |
| 2753 | 2764 | |
| 2754 | 2765 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 2755 | 2766 | zPlural = n==1 ? "" : "s"; |
| 2756 | 2767 | if( zYearMonth ){ |
| 2757 | - blob_appendf(&desc, "%d %s%s for the month beginning %h-01", | |
| 2768 | + blob_appendf(&desc, "%d %s%s for the month beginning %h", | |
| 2758 | 2769 | n, zEType, zPlural, zYearMonth); |
| 2759 | 2770 | }else if( zYearWeek ){ |
| 2760 | 2771 | blob_appendf(&desc, "%d %s%s for week %h beginning on %h", |
| 2761 | 2772 | n, zEType, zPlural, zYearWeek, zYearWeekStart); |
| 2762 | 2773 | }else if( zDay ){ |
| 2763 | 2774 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2379,13 +2379,11 @@ | |
| 2379 | if( zYearMonth ){ |
| 2380 | char *zNext; |
| 2381 | int bZulu = 0; |
| 2382 | const char *zTZMod; |
| 2383 | zYearMonth = timeline_expand_datetime(zYearMonth, &bZulu); |
| 2384 | if( strlen(zYearMonth)>7 ){ |
| 2385 | zYearMonth = mprintf("%.7s", zYearMonth); |
| 2386 | } |
| 2387 | if( db_int(0,"SELECT julianday('%q-01') IS NULL", zYearMonth) ){ |
| 2388 | zYearMonth = db_text(0, "SELECT strftime('%%Y-%%m','now');"); |
| 2389 | } |
| 2390 | zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00"; |
| 2391 | if( db_int(0, |
| @@ -2415,14 +2413,17 @@ | |
| 2415 | blob_append_sql(&cond, |
| 2416 | " AND event.mtime>=julianday('%q-01',%Q)" |
| 2417 | " AND event.mtime<julianday('%q-01',%Q,'+1 month')\n", |
| 2418 | zYearMonth, zTZMod, zYearMonth, zTZMod); |
| 2419 | nEntry = -1; |
| 2420 | } |
| 2421 | else if( zYearWeek ){ |
| 2422 | char *z, *zNext; |
| 2423 | int bZulu = 0; |
| 2424 | zYearWeek = timeline_expand_datetime(zYearWeek, &bZulu); |
| 2425 | z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek); |
| 2426 | if( z && z[0] ){ |
| 2427 | zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')", |
| 2428 | zYearWeek); |
| @@ -2440,33 +2441,43 @@ | |
| 2440 | "SELECT date('now','-6 days','weekday 1');"); |
| 2441 | zYearWeek = db_text(0, |
| 2442 | "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')"); |
| 2443 | } |
| 2444 | } |
| 2445 | zNext = db_text(0, "SELECT date(%Q,'+7 day');", zYearWeekStart); |
| 2446 | if( db_int(0, |
| 2447 | "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" |
| 2448 | " WHERE blob.rid=event.objid AND mtime>=julianday(%Q)%s)", |
| 2449 | zNext, blob_sql_text(&cond)) |
| 2450 | ){ |
| 2451 | zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); |
| 2452 | zNewerButtonLabel = "Following week"; |
| 2453 | } |
| 2454 | fossil_free(zNext); |
| 2455 | zNext = db_text(0, "SELECT date(%Q,'-7 days');", zYearWeekStart); |
| 2456 | if( db_int(0, |
| 2457 | "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" |
| 2458 | " WHERE blob.rid=event.objid AND mtime<julianday(%Q)%s)", |
| 2459 | zYearWeekStart, blob_sql_text(&cond)) |
| 2460 | ){ |
| 2461 | zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); |
| 2462 | zOlderButtonLabel = "Previous week"; |
| 2463 | } |
| 2464 | fossil_free(zNext); |
| 2465 | blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ", |
| 2466 | zYearWeek); |
| 2467 | nEntry = -1; |
| 2468 | } |
| 2469 | else if( zDay ){ |
| 2470 | char *zNext; |
| 2471 | int bZulu = 0; |
| 2472 | const char *zTZMod; |
| @@ -2752,11 +2763,11 @@ | |
| 2752 | db_multi_exec("%s", blob_sql_text(&sql)); |
| 2753 | |
| 2754 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 2755 | zPlural = n==1 ? "" : "s"; |
| 2756 | if( zYearMonth ){ |
| 2757 | blob_appendf(&desc, "%d %s%s for the month beginning %h-01", |
| 2758 | n, zEType, zPlural, zYearMonth); |
| 2759 | }else if( zYearWeek ){ |
| 2760 | blob_appendf(&desc, "%d %s%s for week %h beginning on %h", |
| 2761 | n, zEType, zPlural, zYearWeek, zYearWeekStart); |
| 2762 | }else if( zDay ){ |
| 2763 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2379,13 +2379,11 @@ | |
| 2379 | if( zYearMonth ){ |
| 2380 | char *zNext; |
| 2381 | int bZulu = 0; |
| 2382 | const char *zTZMod; |
| 2383 | zYearMonth = timeline_expand_datetime(zYearMonth, &bZulu); |
| 2384 | zYearMonth = mprintf("%.7s", zYearMonth); |
| 2385 | if( db_int(0,"SELECT julianday('%q-01') IS NULL", zYearMonth) ){ |
| 2386 | zYearMonth = db_text(0, "SELECT strftime('%%Y-%%m','now');"); |
| 2387 | } |
| 2388 | zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00"; |
| 2389 | if( db_int(0, |
| @@ -2415,14 +2413,17 @@ | |
| 2413 | blob_append_sql(&cond, |
| 2414 | " AND event.mtime>=julianday('%q-01',%Q)" |
| 2415 | " AND event.mtime<julianday('%q-01',%Q,'+1 month')\n", |
| 2416 | zYearMonth, zTZMod, zYearMonth, zTZMod); |
| 2417 | nEntry = -1; |
| 2418 | /* Adjust the zYearMonth for the title */ |
| 2419 | zYearMonth = mprintf("%z-01%s", zYearMonth, &"Z"[!bZulu]); |
| 2420 | } |
| 2421 | else if( zYearWeek ){ |
| 2422 | char *z, *zNext; |
| 2423 | int bZulu = 0; |
| 2424 | const char *zTZMod; |
| 2425 | zYearWeek = timeline_expand_datetime(zYearWeek, &bZulu); |
| 2426 | z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek); |
| 2427 | if( z && z[0] ){ |
| 2428 | zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')", |
| 2429 | zYearWeek); |
| @@ -2440,33 +2441,43 @@ | |
| 2441 | "SELECT date('now','-6 days','weekday 1');"); |
| 2442 | zYearWeek = db_text(0, |
| 2443 | "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')"); |
| 2444 | } |
| 2445 | } |
| 2446 | zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00"; |
| 2447 | if( db_int(0, |
| 2448 | "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" |
| 2449 | " WHERE blob.rid=event.objid" |
| 2450 | " AND mtime>=julianday(%Q,%Q)%s)", |
| 2451 | zYearWeekStart, zTZMod, blob_sql_text(&cond)) |
| 2452 | ){ |
| 2453 | zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'+7 day');", |
| 2454 | &"Z"[!bZulu], zYearWeekStart); |
| 2455 | zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); |
| 2456 | zNewerButtonLabel = "Following week"; |
| 2457 | fossil_free(zNext); |
| 2458 | } |
| 2459 | if( db_int(0, |
| 2460 | "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" |
| 2461 | " WHERE blob.rid=event.objid" |
| 2462 | " AND mtime<julianday(%Q,%Q)%s)", |
| 2463 | zYearWeekStart, zTZMod, blob_sql_text(&cond)) |
| 2464 | ){ |
| 2465 | zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'-7 days');", |
| 2466 | &"Z"[!bZulu], zYearWeekStart); |
| 2467 | zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0)); |
| 2468 | zOlderButtonLabel = "Previous week"; |
| 2469 | fossil_free(zNext); |
| 2470 | } |
| 2471 | blob_append_sql(&cond, |
| 2472 | " AND event.mtime>=julianday(%Q,%Q)" |
| 2473 | " AND event.mtime<julianday(%Q,%Q,'+7 days')\n", |
| 2474 | zYearWeekStart, zTZMod, zYearWeekStart, zTZMod); |
| 2475 | nEntry = -1; |
| 2476 | if( fossil_ui_localtime() && bZulu ){ |
| 2477 | zYearWeekStart = mprintf("%zZ", zYearWeekStart); |
| 2478 | } |
| 2479 | } |
| 2480 | else if( zDay ){ |
| 2481 | char *zNext; |
| 2482 | int bZulu = 0; |
| 2483 | const char *zTZMod; |
| @@ -2752,11 +2763,11 @@ | |
| 2763 | db_multi_exec("%s", blob_sql_text(&sql)); |
| 2764 | |
| 2765 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 2766 | zPlural = n==1 ? "" : "s"; |
| 2767 | if( zYearMonth ){ |
| 2768 | blob_appendf(&desc, "%d %s%s for the month beginning %h", |
| 2769 | n, zEType, zPlural, zYearMonth); |
| 2770 | }else if( zYearWeek ){ |
| 2771 | blob_appendf(&desc, "%d %s%s for week %h beginning on %h", |
| 2772 | n, zEType, zPlural, zYearWeek, zYearWeekStart); |
| 2773 | }else if( zDay ){ |
| 2774 |