Merge lp:~doflah/ubuntu-calendar-app/fix_daylight_savings into lp:ubuntu-calendar-app

Proposed by Dennis O'Flaherty
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 99
Merged at revision: 102
Proposed branch: lp:~doflah/ubuntu-calendar-app/fix_daylight_savings
Merge into: lp:ubuntu-calendar-app
Diff against target: 11 lines (+1/-1)
1 file modified
dateExt.js (+1/-1)
To merge this branch: bzr merge lp:~doflah/ubuntu-calendar-app/fix_daylight_savings
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Olivier Tilloy (community) Approve
Review via email: mp+183557@code.launchpad.net

Commit message

Fix the implementation of Date.addDays() wrt DST.

Description of the change

The current implementation of Date#addDays breaks in daylight savings time.

    var d = new Date(2013, 9, 27);
    d.addDays(7).toString(); // "Sun Nov 03 2013 00:00:00 GMT-0400 (EST)"
    d.addDays(8).toString(); // "Sun Nov 03 2013 23:00:00 GMT-0500 (EST)"

so November has two 3rds. This is too many. Using setDate and getDate results in the expected behavior.

    var d = new Date(2013, 9, 27);
    d.addDays(7).toString(); // "Sun Nov 03 2013 00:00:00 GMT-0400 (EST)"
    d.addDays(8).toString(); // "Mon Nov 04 2013 00:00:00 GMT-0500 (EST)"

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Good catch Dennis, thanks for the patch!

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

I keep meaning to add unit tests for the JS libraries, but never actually get around to doing it.
Dennis, any chance you’d be interested in setting up such tests?

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Dennis O'Flaherty (doflah) wrote :

Yeah, I could definitely look into that. What should I be using to write the tests, Autopilot?

Also, what did I do to make Jenkins unhappy?

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

> Yeah, I could definitely look into that. What should I be using to write the
> tests, Autopilot?

No, I was thinking more of headless unit tests (autopilot is for UI integration tests). We could probably leverage QtQuickTest (see http://qt-project.org/doc/qt-5.0/qtquick/qtquick2-qtquick-qtquicktest.html for documentation).

> Also, what did I do to make Jenkins unhappy?

Nothing. The failures are unrelated to your change. It appears there was an API change in the UITK that went in without notice, and it broke a number of applications’ tests. The change has now been reverted, once the new packages are propagated I’ll request a re-run.

Revision history for this message
David Planella (dpm) wrote :

On Tue, Sep 3, 2013 at 1:43 PM, Olivier Tilloy <<email address hidden>
> wrote:

> > Yeah, I could definitely look into that. What should I be using to
> write the
> > tests, Autopilot?
>
> No, I was thinking more of headless unit tests (autopilot is for UI
> integration tests). We could probably leverage QtQuickTest (see
> http://qt-project.org/doc/qt-5.0/qtquick/qtquick2-qtquick-qtquicktest.htmlfor documentation).
>
>
The Calculator app has got some unit tests that can be used as an example:
http://bazaar.launchpad.net/~ubuntu-calculator-dev/ubuntu-calculator-app/trunk/files/head:/unit-tests/

They can be run locally, but at some point we'll need to get Jenkins to run
them as well.

>
> > Also, what did I do to make Jenkins unhappy?
>
> Nothing. The failures are unrelated to your change. It appears there was
> an API change in the UITK that went in without notice, and it broke a
> number of applications’ tests. The change has now been reverted, once the
> new packages are propagated I’ll request a re-run.
> --
>
> https://code.launchpad.net/~dennis-oflaherty/ubuntu-calendar-app/fix_daylight_savings/+merge/183557
> Your team Ubuntu Calendar Developers is subscribed to branch
> lp:ubuntu-calendar-app.
>

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dateExt.js'
2--- dateExt.js 2013-08-17 03:29:15 +0000
3+++ dateExt.js 2013-09-03 02:08:30 +0000
4@@ -37,7 +37,7 @@
5
6 Date.prototype.addDays = function(days) {
7 var date = new Date(this)
8- date.setTime(date.getTime() + Date.msPerDay * days)
9+ date.setDate(date.getDate() + days);
10 return date
11 }
12

Subscribers

People subscribed via source and target branches

to status/vote changes: