Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5631] Android: Timezone is ignored

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionHold
Resolution Date2018-06-19T11:14:52.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labels7.0.2.GA, ANDROID
ReporterAndreas Pingas
AssigneeShak Hossain
Created2018-02-28T10:05:03.000+0000
Updated2018-06-19T11:14:53.000+0000

Description

In certain devices appears the bug i will describe below. For example, when i run the following Ti.API.info('2017-08-14T20:30:00.0Z'); Ti.API.info(new Date('2017-08-14T20:30:00.0Z')); Ti.API.info(new Date('2017-08-14T20:30:00.0Z').getTimezoneOffset()); Ti.API.info(String.formatTime(new Date('2017-08-14T20:30:00.0Z'), 'long')); and i get the following result: [INFO] : 2017-08-14T20:30:00.0Z [INFO] : Mon Aug 14 2017 23:30:00 GMT+0300 (EEST) [INFO] : -180 [INFO] : 12:30 The result is always the same, and doesn't take into account what timezone has the user set on his device. Only on String.formatTime its taken into account. Thank you

Comments

  1. Sharif AbuDarda 2018-02-28

    Hello, What are the devices that have the issue? Please share the details. Thanks.
  2. Andreas Pingas 2018-03-02

    The following devices: Xiaomi mi5 Xiaomi Redmi 4x
  3. Sharif AbuDarda 2018-05-20

    Hello [~andreas.pingas], We don't think it's a bug. Talking about string output differences between Android and iOS, neither are technically wrong, they're just presenting the dates in different ways. In both cases, the given date objects are stored interpreted as universal time. The difference is that Android is outputting the UTC date in local time +/- timezone and iOS is outputting the UTC date as-is (same string given to the Date object) but doesn't output the timezone. Personally, I think Google V8 is handling this better because it clarifies the timezone and Apple's JavaScriptCore is not. But in any case, this is why you should always use String.formatTime(). This is used to output the Date object to your liking. Notice that String.formatTime() outputs the Date object pretty much the same between Android and iOS. Hope this helps. Let us know. Thanks.

JSON Source