From 356c1fb913cd06b040ed8e1717eb642c8b42ad71 Mon Sep 17 00:00:00 2001 From: Blake Lucchesi Date: Tue, 6 Oct 2009 13:06:43 -0700 Subject: [PATCH] Adjust query to properly get year week using YEARWEEK function instead of concating the year and week separately, this fixes the offset for January 1st showing as week 52 of the next year instead of 53 of the previous year. --- public/sites/all/modules/week/week.module | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/public/sites/all/modules/week/week.module b/public/sites/all/modules/week/week.module index 30af743..d055069 100644 --- a/public/sites/all/modules/week/week.module +++ b/public/sites/all/modules/week/week.module @@ -177,7 +177,7 @@ function week_links_query($node_types) { // WEEK(date, 3) gets precisely the ISO-8601 week number that PHP uses so I can calculate the first and last day of the week in the token module hooks $date_first_day = variable_get('date_first_day', 1); $week_option = $date_first_day == 1 ? '%v' : '%V'; - $query = "SELECT CONCAT(DATE_FORMAT(FROM_UNIXTIME(created), '%Y'),DATE_FORMAT(FROM_UNIXTIME(created), '$week_option')) AS yearweek, + $query = "SELECT YEARWEEK(DATE_FORMAT(FROM_UNIXTIME(created), '%Y-%m-%%d')) AS yearweek, COUNT(CONCAT(DATE_FORMAT(FROM_UNIXTIME(created), '%Y'),DATE_FORMAT(FROM_UNIXTIME(created), '$week_option'))) AS postcount, DATE_FORMAT(FROM_UNIXTIME(created), '%Y') AS year, DATE_FORMAT(FROM_UNIXTIME(created), '$week_option') AS week, -- 1.6.1.3