{ "id": "171659", "key": "TIMOB-26044", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2018-05-16T01:39:25.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "engReviewed", "parity", "picker" ], "versions": [], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-05-21T16:55:06.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{color:red}After thinking about it, perhaps this behavior is okay. If you want the year/month/day parts preserved, then you should be using the {{Ti.UI.PICKER_TYPE_DATE_AND_TIME}} type. Especially since one problem with preserving the date in a {{Ti.UI.PICKER_TYPE_TIME}} is it has a daylight savings time issue where 2 AM cannot be selected on a spring-forward day (such as 2018/03/11), which is currently the case for both Android and iOS. This behavior would be okay in a date-time picker, but perhaps not in a time-only picker.{color}\r\n\r\n*Summary:*\r\nA {{Ti.UI.Picker}} of type {{PICKER_TYPE_TIME}} does not retain the originally assigned year, month, day, and seconds assigned to its {{value}} property. The date returned by {{value}} is always set to the current date (this is wrong), with the hour and minute components set to what's selected in the picker (this last part is fine).\r\n\r\nOn iOS, all other date components (year, month, day, seconds) are preserved. Android should do the same.\r\n\r\n*Test:*\r\n# Build and run the below code on Android.\r\n# Tap the \"Get Selected Time\" button.\r\n# An alert dialog displays the picker's current date and time. Note that the date is set to current day instead of the hardcoded 2018/01/01.\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nvar picker = Ti.UI.createPicker({\r\n\ttype: Ti.UI.PICKER_TYPE_TIME,\r\n\tvalue: new Date(2018, 0, 1, 12),\r\n});\r\nwindow.add(picker);\r\nvar button = Ti.UI.createButton({\r\n\ttitle: \"Get Selected Time Value\",\r\n\tbottom: \"20dp\",\r\n});\r\nbutton.addEventListener(\"click\", function(e) {\r\n\tvar date = picker.value;\r\n\tvar dialog = Ti.UI.createAlertDialog({\r\n\t\ttitle: \"Selected Time\",\r\n\t\tmessage: date.toString(),\r\n\t});\r\n\tdialog.show();\r\n});\r\nwindow.add(button);\r\nwindow.open();\r\n{code}\r\n\r\n*Note:*\r\nThis is an issue with Titanium's \"TiUITimeSpinner\" Java class...\r\n[TiUITimeSpinner.java|https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/picker/TiUITimeSpinner.java]\r\n\r\n*Work-Around:*\r\nYou can extract the hour and minute selected from the picker and recreate a date object with the correct time like this...\r\n{code:javascript}\r\nvar originalDate = new Date(2018, 0, 1, 12);\r\npicker.value = originalDate;\r\npicker.addEventListener(\"change\", function(e) {\r\n\tvar newDate = new Date(originalDate.getTime());\r\n\tnewDate.setHours(picker.value.getHours());\r\n\tnewDate.setMinutes(picker.value.getMinutes());\r\n});\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: Time picker \"value\" property does not retain assigned year/month/day like iOS", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }