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.
Your Answer
Think you can help? Login to answer this question!