Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1707] Date Picker off by a year on iOS 4 sdk 1.4 & 1.4.1

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-07-25T17:57:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsdate, defect, ios, iphone, picker
Reporterctredway
AssigneeNeeraj Gupta
Created2011-04-15T03:00:05.000+0000
Updated2012-07-26T22:18:55.000+0000

Description

Using the KS as the example, whenever you move the Date Picker from Jan 1 to Jan 2 (by moving the day-of-month up 1) for any year, the 'change' event handler's e.value.getFullYear() [and e.value.getUTCFullYear() for that matter] is off by one year.

http://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/picker_date1.js"> http://github.com/appcelerator/titanium_mobile/blob/master/demos/Ki...

Comments

  1. Stephen Tramer 2012-07-25

    Cannot reproduce in SDK 2.2.0.014b86f on iPhone Sim 5.1. Test code:
       var win = Titanium.UI.createWindow();
       win.backgroundColor = 'black';
       
       var minDate = new Date();
       minDate.setFullYear(2009);
       minDate.setMonth(0);
       minDate.setDate(1);
       
       var maxDate = new Date();
       maxDate.setFullYear(2009);
       maxDate.setMonth(11);
       maxDate.setDate(31);
       
       var value = new Date();
       value.setFullYear(2009);
       value.setMonth(0);
       value.setDate(1);
       
       var picker = Ti.UI.createPicker({
           type:Ti.UI.PICKER_TYPE_DATE,
           minDate:minDate,
           maxDate:maxDate,
           value:value
       });
       
       // turn on the selection indicator (off by default)
       picker.selectionIndicator = true;
       
       win.add(picker);
       
       var label = Ti.UI.createLabel({
           text:'Choose a date',
           top:6,
           width:'auto',
           height:'auto',
           textAlign:'center',
           color:'white'
       });
       win.add(label);
       
       picker.addEventListener('change',function(e)
       {
           label.text = e.value.toLocaleString();
           Ti.API.info(e.value.getFullYear());
           Ti.API.info(e.value.getUTCFullYear());
       });
       
       var locale = false;
       var localebutton = Ti.UI.createButton({
           title:'Change locale',
           bottom:20,
           width:200,
           height:40
       });
       localebutton.addEventListener('click', function() {
           if (!locale) {
               picker.setLocale('ru');
               locale = true;
           }
           else {
               locale = false;
               picker.setLocale(Titanium.Platform.locale);
           }
       });
       win.add(localebutton);
       win.open();
       

JSON Source