Time Picker does not set 15 minutes or 45 minutes correctly

You must Login before you can answer or comment on any questions.

Take a look at the following code fragment:

var win = Titanium.UI.createWindow({
                            title : ' Reminder Time',
                            layout: 'vertical'
                        });
 
                        var now = new Date();
 
                        if(thisTime == null){
                            thisTime = new Date('Thu Oct 11 2012 00:00:00 GMT-0700 (PDT)');
                            thisTime.setHours(now.getHours());
                            thisTime.setMinutes((Math.floor(now.getMinutes()/15) * 15) % 60);
                        }
 
                        var picker = Ti.UI.createPicker({
                            type : Ti.UI.PICKER_TYPE_TIME,
                            minuteInterval: 15,
                            value : thisTime,
                            top: 25
                        });
 
                        labelPicker = Ti.UI.createLabel({
                            top: 25,
                            color:'#fff',
                            font:{fontSize:16},
                            text : thisTime.toString()
                        });
                        win.add(labelPicker);
 
                        picker.addEventListener('change', function(e) {
                            thisTime = e.value
                            labelPicker.text = thisTime.toString();
                        });
 
                        win.add(picker);
When the we set the minutes to 15 the picker shows 45 and when we set the minutes to 45 it shows 15. thisTime.setMinutes((Math.floor(now.getMinutes()/15) * 15) % 60); rounds down the nearest 15 minutes. So when it is 12:26 it gets rounded to 12:15 but the picker shows 12:45.

Is this a bug or am I missing something here?

Thanks.

— asked 8 months ago by Kam Rezvani
7 Comments
  • Which Platform is? What Ti SDK are you attempting to use?

    And, an actual whole sample might help to diagnose the problem.

    — commented 7 months ago by Eduardo Gomez

  • Hi Eduardo - thanks for addressing this problem. This is the iOS platform & I am using is 2.1.2GA. The code fragment I provided is, I believe enough to diagnose the problem. So just push any hour & minute combination to the picker and you will see that the 15 & 45 minutes are no showing properly. Let me know if you still want more information because I would really like to have this problem addressed.

    — commented 7 months ago by Kam Rezvani

  • Hi Kam, I got couple more questions:

    Where should the win object get open and, Where is thisTime set?

    [ERROR] Script Error = Can't find variable: thisTime at app.js (line 8).

    — commented 7 months ago by Eduardo Gomez

  • Show 4 more comments

Your Answer

Think you can help? Login to answer this question!