Results 1 to 4 of 4

Thread: Problem datefield format 'm/Y'

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1

    Default Problem datefield format 'm/Y'

    When the computer's date is January 31 of any year, it happens a bug in the 'datefield' when the attribute 'format' is 'm/Y'. If you select any day of February, it changes to 31 March. This happens all the months that do not end with 31 (February, April, June, September and November). In testing, I changed the date of my machine to 31/01/2011. Can anyone help? Following is the code used.

    {
    xtype: 'datefield',
    fieldLabel: 'Month/Year',
    format: 'm/Y',
    allowBlank: false,
    listeners: {
    change: function(field, newValue, oldValue){
    alert(newValue);
    alert(field.getValue().format('d/m/Y'));
    alert(field.getValue().format('m/Y'));
    }
    }

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    The issue is that month 02 is actually that of March... months start at 0. Native javascript:

    new Date(2012, 02)

    Will give you March 01 2012
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3

    Lightbulb

    Hello, thanks for the reply.
    The format 'm/Y' returns:
    'm': Numeric representation of a month, with leading zeros (01 to 12)
    'Y': A full numeric representation of a year, 4 digits (Examples: 1999 or 2003)
    To test:
    - Change the date of your system, for example, January 31, 2011.
    - Create a date field as the code I posted.
    - Select any day in the calendar month of February 2011.
    The value of the field should be shown in the '02/2011'. Right? But it shows '03/2011' which corresponds to the month of March. If I selected February because it showed in March?
    Do you understand the problem now? Is it a bug? Is there any override to correct this behavior?
    Thank you again.

  4. #4
    Sencha User
    Join Date
    Jul 2009
    Location
    Colorado Springs, CO
    Posts
    52

    Default

    Quote Originally Posted by maxbsousa View Post
    Hello, thanks for the reply.
    The format 'm/Y' returns:
    'm': Numeric representation of a month, with leading zeros (01 to 12)
    'Y': A full numeric representation of a year, 4 digits (Examples: 1999 or 2003)
    To test:
    - Change the date of your system, for example, January 31, 2011.
    - Create a date field as the code I posted.
    - Select any day in the calendar month of February 2011.
    The value of the field should be shown in the '02/2011'. Right? But it shows '03/2011' which corresponds to the month of March. If I selected February because it showed in March?
    Do you understand the problem now? Is it a bug? Is there any override to correct this behavior?
    Thank you again.

    I've seen the same behavior above, was a solution for this issue this ever found? Seems that if you change the date format as mentioned above to 'm/Y' for some reason date field converts to Feb to March. If you leave date format as default 'm/d/Y' everything works fine.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •