[AC-2347] iOS 6: DatePicker dates between February 16, 1986 and February 28, 1986 are wrongly reported
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2013-03-15T18:16:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | date, datepicker, datetime, locale, picker, triage |
Reporter | Ygor Lemos |
Assignee | Mauro Parra-Miranda |
Created | 2012-10-30T23:07:45.000+0000 |
Updated | 2017-02-15T00:22:13.000+0000 |
Description
When getting the value back from a datepicker "change" event, the returned values from February 16, 1986 to February 28, 1986 are reported wrong. All other dates are reported normally. No date treatment is being made on the event data.
var win = Ti.UI.createWindow();
// Picker Animations
var slideIn = Ti.UI.createAnimation({
bottom : -40
});
var slideOut = Ti.UI.createAnimation({
bottom : -288
});
// Birthday Picker
var birthPickerView = Ti.UI.createView({
height : 288,
//bottom : -288,
zIndex : 9
});
var birthPicker = Ti.UI.createPicker({
top : 40,
type : Ti.UI.PICKER_TYPE_DATE,
locale : Ti.Platform.locale,
selectionIndicator : true,
minDate : new Date(1900, 0, 1),
maxDate : new Date(1997, 11, 31)
});
birthPickerView.add(birthPicker);
var birthPickerLabel = Ti.UI.createLabel({
text : "Your Birthday",
color : "#fff",
font : {
fontWeight : "bold",
fontSize : 16
},
shadowColor : "#000",
shadowOffset : {
x : 0.5,
y : 0.5
}
});
birthPickerSpace = Ti.UI.createButton({
style : Ti.UI.iPhone.SystemButtonStyle.FIXED_SPACE,
width : 29
}, function() {
});
birthPickerOKButton = Ti.UI.createButton({
title : "Confirm",
style : Ti.UI.iPhone.SystemButtonStyle.DONE
}, function() {
birthPickerView.animate(slideOut);
});
var birthPickerToolbar = Ti.UI.iOS.createToolbar({
top : 0,
height : 40,
items : [birthPickerLabel, birthPickerSpace, birthPickerOKButton]
});
birthPickerView.add(birthPickerToolbar);
win.add(birthPickerView);
birthPicker.addEventListener("change", function(e) {
console.log("Date Object: " + e);
console.log("Date Value: " + e.value);
console.log("Date: " + e.value.getDate());
console.log("Day: " + e.value.getDay());
console.log("Date String: " + e.value.toDateString());
console.log("ISO String: " + e.value.toISOString());
console.log("Full Date: " + e.value.toString());
var selDate = "Formatted Date: " + e.value.getDate() + "/" + String(Number(e.value.getMonth()) + 1) + "/" + e.value.getFullYear();
console.log(selDate);
//fBirthdayLabel.setText(selDate);
});
win.open();
Example:
Selected Date: February 14, 1986
[INFO] {
source = "[object TiUIPicker]";
type = change;
value = "1986-02-14 02:00:00 +0000";
}
[INFO] 1986-02-14 02:00:00 +0000
[INFO] 14
[INFO] 5
[INFO] Fri Feb 14 1986
[INFO] 1986-02-14T02:00:00.000Z
[INFO] Fri Feb 14 1986 00:00:00 GMT-0200 (BRST)
Selected Date: February 18, 1986
[INFO] {
source = "[object TiUIPicker]";
type = change;
value = "1986-02-18 02:00:00 +0000";
}
[INFO] 1986-02-18 02:00:00 +0000
[INFO] 17
[INFO] 1
[INFO] Mon Feb 17 1986
[INFO] 1986-02-18T02:00:00.000Z
[INFO] Mon Feb 17 1986 23:00:00 GMT-0300 (BRT)
So as you might see, the objects returned on Feb are returned with times different than 0, so, every date between the aforementioned range is getting returned with one day less when you call .getDate() on the result value of the change event.
It might be related to locale, but if I left locale out I lose the picker translation and that is unacceptable.
Any hints?
Attachments
File | Date | Size |
---|---|---|
datepicker-pt-br.png | 2012-12-06T23:04:02.000+0000 | 90410 |