← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

Re: [Merge] lp:~pkunal-parmar/ubuntu-calendar-app/WeekNumber into lp:ubuntu-calendar-app

 

Review: Needs Fixing

If you watch the video, it shows going to dayview selects the 19th of April, which imho, would be the start of week 17. But it still displays week 16.

http://91.189.93.70:8080/job/generic-mediumtests-utopic/2626/artifact/calendar_app.tests.test_dayview.TestDayView.test_default_view.ogv

I also wonder why selecting dayview takes you to the following week, instead of the current week.

Diff comments:

> === modified file 'TimeLineBaseComponent.qml'
> --- TimeLineBaseComponent.qml	2015-02-19 13:50:29 +0000
> +++ TimeLineBaseComponent.qml	2015-04-22 11:46:51 +0000
> @@ -31,7 +31,7 @@
>      property var keyboardEventProvider;
>  
>      property date startDay: DateExt.today();
> -    property int weekNumber: startDay.weekNumber();
> +    property int weekNumber: startDay.weekNumber(Qt.locale().firstDayOfWeek);
>      property bool isActive: false
>      property alias contentY: timeLineView.contentY
>      property alias contentInteractive: timeLineView.interactive
> 
> === modified file 'TimeLineHeader.qml'
> --- TimeLineHeader.qml	2015-04-17 05:34:37 +0000
> +++ TimeLineHeader.qml	2015-04-22 11:46:51 +0000
> @@ -45,8 +45,9 @@
>              Label{
>                  id: weekNumLabel
>                  objectName: "weeknumber"
> -                // TRANSLATORS: W refers to Week, followed by the actual week number (%1)
> -                text: i18n.tr("W%1").arg(root.weekNumber)
> +
> +		// TRANSLATORS: W refers to Week, followed by the actual week number (%1)
> +                text: i18n.tr("W%1").arg(startDay.weekNumber(Qt.locale().firstDayOfWeek))
>                  fontSize: "small"
>                  height: units.gu(5)
>                  width: parent.width
> 
> === modified file 'dateExt.js'
> --- dateExt.js	2014-08-18 16:48:54 +0000
> +++ dateExt.js	2015-04-22 11:46:51 +0000
> @@ -85,16 +85,10 @@
>      return this.midnight().addDays(1 - this.getDate())
>  }
>  
> -Date.prototype.weekNumber = function() {
> -    var date = this.weekStart(1).addDays(3) // Thursday midnight
> -    var newYear = new Date(date.getFullYear(), 0 /*Jan*/, 1 /*the 1st*/)
> -    var n = 0
> -    var tx = date.getTime(), tn = newYear.getTime()
> -    while (tn < tx) {
> -        tx = tx - Date.msPerWeek
> -        n = n + 1
> -    }
> -    return n
> +Date.prototype.weekNumber = function(weekStartDay) {
> +    var date = this.weekStart(weekStartDay).addDays(3) // Thursday midnight
> +    var onejan = new Date(this.getFullYear(), 0, 3);
> +    return Math.ceil((((date - onejan) / 86400000) + onejan.getDay()+1)/7);
>  }
>  
>  Date.prototype.weeksInMonth = function(weekday) {
> 
> === modified file 'tests/autopilot/calendar_app/tests/test_dayview.py'
> --- tests/autopilot/calendar_app/tests/test_dayview.py	2015-04-10 18:50:59 +0000
> +++ tests/autopilot/calendar_app/tests/test_dayview.py	2015-04-22 11:46:51 +0000
> @@ -20,6 +20,7 @@
>  
>  import datetime
>  import calendar
> +import logging
>  
>  # from __future__ import range
>  # (python3's range, is same as python2's xrange)
> @@ -33,6 +34,8 @@
>  from calendar_app.tests import CalendarAppTestCase
>  from datetime import date
>  
> +logger = logging.getLogger(__name__)
> +
>  
>  class TestDayView(CalendarAppTestCase):
>  
> @@ -72,9 +75,14 @@
>          self.assertEquals(
>              self.day_view.get_datelabel(today).text, str(now.day))
>  
> +        week = int(now.strftime("%U"))+1
> +
> +        logger.warn(now)

These can be logger.debug statements

> +        logger.warn(str(week))
> +        logger.warn(self.day_view.get_weeknumer(today).text)
>          # Checking week number is  correct
>          self.assertEquals(
> -            self.day_view.get_weeknumer(today).text, 'W' + now.strftime("%W"))
> +            self.day_view.get_weeknumer(today).text, 'W' + str(week))
>  
>          # Check  day is scrolled to the current time
>          self.assertEquals(self.day_view.get_scrollHour(), now.hour)
> 


-- 
https://code.launchpad.net/~pkunal-parmar/ubuntu-calendar-app/WeekNumber/+merge/255078
Your team Ubuntu Calendar Developers is subscribed to branch lp:ubuntu-calendar-app.


References