[regression] first day of the month is broken for some months

Bug #1202366 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Calendar App
Fix Released
Critical
Olivier Tilloy

Bug Description

This is better explained by a few screenshots (courtesy of Kunal):

  http://ubuntuone.com/7O0UlY3RAT4wvSxOctDpq4
  http://ubuntuone.com/3CWSpaxJ15IynbOIACPJ6V
  http://ubuntuone.com/5DVRYl8nhT8xuWc6n3nrXw

This appears to be a regression introduced by revision 66 in trunk (which fixed bug #1198652). Confirmed by selectively reverting this revision, and verifying that it fixed the issue.

Related branches

Revision history for this message
Olivier Tilloy (osomon) wrote :

In dateExt.js, in the midnight() function, changing

    date.setHours(0,0,0,0);

to

    date.setUTCHours(0,0,0,0);

fixes the issue. However bug #1198652 is back.
This is basically because the current date in UTC is not necessarily the same as the current date in the user’s location.

Revision history for this message
Olivier Tilloy (osomon) wrote :

To clarify my previous comment: the previous implementation

    Date.prototype.midnight = function() {
        var date = new Date(this)
        var t = date.getTime()
        if (t % Date.msPerDay != 0)
            date.setTime(t - t % Date.msPerDay)
        return date
    }

is strictly equivalent to:

    Date.prototype.midnight = function() {
        var date = new Date(this)
        date.setUTCHours(0,0,0,0)
        return date
    }

However both are wrong, because date is constructed as a local date object, so calling setUTCHours() on it doesn’t make sense.

So the current implementation, as found in trunk, is correct, assuming that midnight is supposed to return the current date at midnight in local time. The MonthView is probably assuming that midnight returns a UTC date.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Interestingly, I can observe the issue with my local time, but if I change my time zone to GMT-7 (US west coast), I can’t see it anymore. There is obviously a mix of UTC times and local times somewhere that messes the view.

Olivier Tilloy (osomon)
Changed in ubuntu-calendar-app:
status: Confirmed → In Progress
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:ubuntu-calendar-app at revision 75, scheduled for release in ubuntu-calendar-app, milestone alpha-1

Changed in ubuntu-calendar-app:
status: In Progress → Fix Committed
Olivier Tilloy (osomon)
Changed in ubuntu-calendar-app:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.