{ "id": "173051", "key": "TIMOB-26858", "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": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2020-05-11T23:15:57.000+0000", "created": "2019-02-25T10:28:53.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "engSchedule" ], "versions": [], "issuelinks": [ { "id": "58366", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "175002", "key": "TIMOB-27892", "fields": { "summary": "Android: Update toLocale*String() methods to support locale/options", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "subtask": false } } } }, { "id": "57735", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "173876", "key": "TIMOB-27240", "fields": { "summary": "Android: Add Intl.NumberFormat support", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-05-11T23:15:57.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "When calling {{toLocaleDateString}} on a {{Date}} object, the output is different on iOS and Android.\r\n\r\nTest-Case (expecting German locale):\r\n{code}\r\nnew Date(2019, 1, 25).toLocaleDateString('de-DE')\r\n{code}\r\n\r\nOutput iOS (and Chrome):\r\n{code}\r\n25.02.2019\r\n{code}\r\n\r\nOutput Android:\r\n{code}\r\nMon Feb 25 2019\r\n{code}\r\n\r\nThis is a parity issue for as, as we'd like to use localized dates for our users. Hopefully it's just a tweak in V8!", "attachment": [], "flagged": false, "summary": "Android (V8): toLocaleDateString has different outputs on iOS and Android", "creator": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "446294", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The real issue here is that Android's {{Date.toLocaleDataString()}} method doesn't support a 2nd argument that allows you to specify how you want the month, day, and year to appear. That is what you really need.\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString\r\n\r\nFor now, your only option is to use Titanium's [String.formatDate()|https://docs.appcelerator.com/platform/latest/#!/api/Global.String-method-formatDate] function. It will provide consistent results between platforms.\r\n{code:javascript}\r\nvar date = new Date(Date.UTC(2019, 1, 31));\r\nconsole.log(String.formatDate(date, \"short\"));\r\n// \"en-us\" output: 1/31/19\r\n{code}\r\n\r\nUnfortunately, none of the format strings for {{String.formatDate()}} support a {{MM/DD/YYYY}} or {{DD/MM/YYYY}} format where it shows leading zeros for the month or day or 4 digit years. I believe this is the format you are after.\r\n\r\nOr... perhaps another alternative solution is to hard-code the date format too YYYY-MM-DD. The below works on Android, but it doesn't work on iOS and I'm not sure why at the moment. (Would need to isolate later.)\r\n{code:javascript}\r\nvar date = new Date(Date.UTC(2019, 1, 5));\r\nconsole.log(String.format(\"%04d-%02d-%02d\", date.getFullYear(), date.getMonth() + 1, date.getDate()));\r\n// Android outputs: 2019-01-05\r\n// iOS outputs: 000-00-07\r\n{code}\r\n\r\nBut right, supporting the {{Date.setLocaleDateString()}} method's 2nd argument is the ultimate solution.", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-02-25T20:34:56.000+0000", "updated": "2019-02-26T18:41:31.000+0000" }, { "id": "446295", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks for the input! For now, we went with the {{date-fns}} method {{format}} that takes a locale as well. How can it be that Android would not support this? Does it a ship with a different V8 revision?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-02-25T20:44:14.000+0000", "updated": "2019-02-25T20:44:14.000+0000" }, { "id": "446299", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Part of the problem is that the Android NDK C/C++ side does not support locale at all. For example, C functions such as {{setlocale()}} will no-op and the locale will always default to effectively \"en-us\" (ie: C++ {{std::locale::classic}}). This is a limitation on Google's end. I'm pretty sure our only option is to override the JavaScript functions and do the locale formatting on the Java side.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-02-25T21:58:30.000+0000", "updated": "2019-02-25T21:58:30.000+0000" }, { "id": "455437", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~hknoechel], I'm closing this ticket in favor of [TIMOB-27892].\r\nSorry. I forgot about this ticket and wrote up a duplicate, but the good news is that the other ticket has a working PR that does what you want. :)", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2020-05-11T23:13:31.000+0000", "updated": "2020-05-11T23:13:31.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }