Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Adobe Flex SDK 4.6 (Release)
    • Fix Version/s: Apache Flex 4.10.0
    • Component/s: Mobile: DateSpinner
    • Labels:
      None
    • Environment:
      Both mobile (iOS) and desktop (Mac) I've tested it

      Description

      As reported on http://stackoverflow.com/questions/9126194/flex-mobile-4-6-datespinner-dateandtime-jumping-from-jan-31st-to-march-1st:

      set the date in DateSpinner to January 30 or 31 (using mouse or touch)
      click (mouse or touch) on February 1 (visible one or two rows below on the DateSpinner)
      The Datespinner does spin forward but does not stop at February 1: it jumps to March 1. The same behavior can be observed with March 31 - mouse click on April 1 causes a jump to May 1; with May 31 - mouse click on June 1 jumping to July 1, and so on.

      I suspect this behavior is related to the fact that the next month has less days than the prior month (30 instead of 31, or 29 in the case of February 2012), but it is not the behavior that I would like to see when following these two steps. Does anyone know a workaround or fix?

      When the DateSpinner is set with displayMode as 'date' all is well, but that doesn't work in my use case.

        Activity

        Hide
        Carol Frampton added a comment -

        @ Fréderic - this section of code is just suppose to set the date, not the time.

        @Justin - Since the year is set first and then the month and date together, I believe to/from leap years will work correctly.

        Show
        Carol Frampton added a comment - @ Fréderic - this section of code is just suppose to set the date, not the time. @Justin - Since the year is set first and then the month and date together, I believe to/from leap years will work correctly.
        Hide
        Carol Frampton added a comment -

        Author: cframpton
        Date: Mon Jan 14 16:31:09 2013
        New Revision: 1432981

        URL: http://svn.apache.org/viewvc?rev=1432981&view=rev
        Log:
        Refix FLEX-33347. Add DS_mode_date_time_forward_date_to_month_with_fewer_days test. The trick is to set the month and the day with one method call so that if we're going from a month with more days to a month with fewer days or vice versa the date verfication doesn't happen until both parts are set.

        Modified:
        flex/sdk/branches/develop/frameworks/projects/mobilecomponents/src/spark/components/DateSpinner.as
        flex/sdk/branches/develop/mustella/tests/mobile/components/DateSpinner/properties/DS_properties_displayMode_tester.mxml

        Show
        Carol Frampton added a comment - Author: cframpton Date: Mon Jan 14 16:31:09 2013 New Revision: 1432981 URL: http://svn.apache.org/viewvc?rev=1432981&view=rev Log: Refix FLEX-33347 . Add DS_mode_date_time_forward_date_to_month_with_fewer_days test. The trick is to set the month and the day with one method call so that if we're going from a month with more days to a month with fewer days or vice versa the date verfication doesn't happen until both parts are set. Modified: flex/sdk/branches/develop/frameworks/projects/mobilecomponents/src/spark/components/DateSpinner.as flex/sdk/branches/develop/mustella/tests/mobile/components/DateSpinner/properties/DS_properties_displayMode_tester.mxml
        Hide
        Fréderic Cox added a comment - - edited

        Why is the fix not this? It works for my use-case and did not find a bug in my testing. So I'm unsure why fullYear, date and month are manually set instead of using the new Date assignment

        case dateList:
        // for DATE_AND_TIME mode data is a Date.time value
        if (displayMode == DateSelectorDisplayMode.DATE_AND_TIME)

        { newDate = new Date(newValue.data); /*newDate.fullYear = spinnerDate.fullYear; newDate.date = spinnerDate.date; newDate.month = spinnerDate.month;*/ }
        Show
        Fréderic Cox added a comment - - edited Why is the fix not this? It works for my use-case and did not find a bug in my testing. So I'm unsure why fullYear, date and month are manually set instead of using the new Date assignment case dateList: // for DATE_AND_TIME mode data is a Date.time value if (displayMode == DateSelectorDisplayMode.DATE_AND_TIME) { newDate = new Date(newValue.data); /*newDate.fullYear = spinnerDate.fullYear; newDate.date = spinnerDate.date; newDate.month = spinnerDate.month;*/ }
        Hide
        Fréderic Cox added a comment -

        When you set the date on Feb 1 and then on Jan 31 it jumps to Jan 3

        Show
        Fréderic Cox added a comment - When you set the date on Feb 1 and then on Jan 31 it jumps to Jan 3
        Hide
        Fréderic Cox added a comment -

        Also found another bug while testing your previous fix. Now when you set the date on March 31st it won't jump to May 1st when you select April 1st. But when you have the date set on 1st of April and then select the 31st of March (so you go back) then it will jump to the 1st of March

        Show
        Fréderic Cox added a comment - Also found another bug while testing your previous fix. Now when you set the date on March 31st it won't jump to May 1st when you select April 1st. But when you have the date set on 1st of April and then select the 31st of March (so you go back) then it will jump to the 1st of March
        Hide
        Carol Frampton added a comment -

        Reopen. From my quick scan of the code it looks like Justin is right about leap years. The fullYear needs to be set before the date in the change handler.

        Show
        Carol Frampton added a comment - Reopen. From my quick scan of the code it looks like Justin is right about leap years. The fullYear needs to be set before the date in the change handler.
        Hide
        Justin Mclean added a comment -

        There might a similar issue involving leap years and Feb 29th when changing the year to an non leap year

        Show
        Justin Mclean added a comment - There might a similar issue involving leap years and Feb 29th when changing the year to an non leap year
        Hide
        Fréderic Cox added a comment -

        My bad! New to this .. thanks

        Show
        Fréderic Cox added a comment - My bad! New to this .. thanks
        Hide
        Carol Frampton added a comment -

        It isn't set twice. The diff shows the removed line and the new lines.

        case dateList:
        // for DATE_AND_TIME mode data is a Date.time value
        + // Must set date before the month to ensure the date is valid for the
        + // month. If newDate is Jan 31 and you set the month to Feb it will change
        + // the month to March since Feb 31 is not a valid date.
        if (displayMode == DateSelectorDisplayMode.DATE_AND_TIME)

        { var spinnerDate:Date = new Date(newValue.data); newDate.fullYear = spinnerDate.fullYear; - newDate.month = spinnerDate.month; newDate.date = spinnerDate.date; + newDate.month = spinnerDate.month; }
        Show
        Carol Frampton added a comment - It isn't set twice. The diff shows the removed line and the new lines. case dateList: // for DATE_AND_TIME mode data is a Date.time value + // Must set date before the month to ensure the date is valid for the + // month. If newDate is Jan 31 and you set the month to Feb it will change + // the month to March since Feb 31 is not a valid date. if (displayMode == DateSelectorDisplayMode.DATE_AND_TIME) { var spinnerDate:Date = new Date(newValue.data); newDate.fullYear = spinnerDate.fullYear; - newDate.month = spinnerDate.month; newDate.date = spinnerDate.date; + newDate.month = spinnerDate.month; }
        Hide
        Fréderic Cox added a comment -

        Thanks for this fix! And so quickly! I notice you set the month twice now. Is that for a specific reason?

        newDate.month = spinnerDate.month;
        newDate.date = spinnerDate.date;
        newDate.month = spinnerDate.month;

        Show
        Fréderic Cox added a comment - Thanks for this fix! And so quickly! I notice you set the month twice now. Is that for a specific reason? newDate.month = spinnerDate.month; newDate.date = spinnerDate.date; newDate.month = spinnerDate.month;
        Hide
        Carol Frampton added a comment -

        Author: cframpton
        Date: Fri Jan 11 16:10:21 2013
        New Revision: 1432122

        URL: http://svn.apache.org/viewvc?rev=1432122&view=rev
        Log:
        FLEX-33347 - If DateSpinner is in dateAndTime mode you can't spin forward from Jan 31 to date in February or if set on March 31 can't spin forward to date in April, etc. The fix is to set the date variable's month field before the date field (day of the month). If the date is Jan 31 and you set the month to February, since Feb 31 isn't valid, Flash sets the month to March. Unfortunately I don't think there is a workaround for this bug.

        Modified:
        flex/sdk/branches/develop/frameworks/projects/mobilecomponents/src/spark/components/DateSpinner.as

        Show
        Carol Frampton added a comment - Author: cframpton Date: Fri Jan 11 16:10:21 2013 New Revision: 1432122 URL: http://svn.apache.org/viewvc?rev=1432122&view=rev Log: FLEX-33347 - If DateSpinner is in dateAndTime mode you can't spin forward from Jan 31 to date in February or if set on March 31 can't spin forward to date in April, etc. The fix is to set the date variable's month field before the date field (day of the month). If the date is Jan 31 and you set the month to February, since Feb 31 isn't valid, Flash sets the month to March. Unfortunately I don't think there is a workaround for this bug. Modified: flex/sdk/branches/develop/frameworks/projects/mobilecomponents/src/spark/components/DateSpinner.as

          People

          • Assignee:
            Carol Frampton
            Reporter:
            Fréderic Cox
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development