Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25791] Android: getTime issue with 7.0.2 sdk in android

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionWon't Fix
Resolution Date2018-05-05T12:47:49.000+0000
Affected Version/sRelease 7.0.2
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterAminul Islam
AssigneeJoshua Quick
Created2018-02-20T19:43:12.000+0000
Updated2018-05-16T21:45:22.000+0000

Description

Hi, There is an issue in the SDK 7.0.2 with the getTime() function in Android. Issue:- new Date("2018-02-20T11:30:00").getTime() has discrepancy with the old sdk's ( same function is returning different values(milliseconds) in old sdk and new sdk. 1519104600000 - new sdk (7.0.2.GA) 1519126200000 - old sdk (6.3.0.GA) steps to recreate:- 1)calculate the milliseconds using new Date("2018-02-20T11:30:00").getTime() in 7.0.2 and 6.3.0. 2)copy that in check the local time and UTC in http://currentmillis.com. 3) you should see the difference in two SDK's. Test Code:
var win = Ti.UI.createWindow({
 backgroundColor : '#fff'
});
var sf=new Date("2018-02-20T11:30:00").getTime();
Ti.API.info(sf);
alert(sf);
win.open();

Comments

  1. Joshua Quick 2018-02-20

    This is an intentional breaking change Google has made in their V8 JavaScript engine. Google has made this breaking change back in 2015. https://bugs.chromium.org/p/chromium/issues/detail?id=543320 The issue is that the V8 JavaScript Date constructor and parse() method will interpret "YYYY-MM-DDTHH:MM:SS" as local time instead of UTC/GMT time as of 2015. This change can be seen in Google's Chrome browser and in node.js (which uses V8). Titanium upgraded to a newer version of V8 on Android as of Titanium 7.0.0, which is why you're now seeing this breaking change. Unfortunately, Apple's JavaScripCore scripting engine does not have the same behavior and interprets that same datetime string as UTC, not local time. This difference can be seen in the Safari web browser. (It's a bummer I know.) Now, here's what you can do to make it work on all platforms. According to the ISO-8601 datetime spec, you are supposed to append a capital 'Z' to the end of this datetime string which tells the system to interpret it as UTC, not local time. I've tested this and it works on both Android and iOS. https://www.w3.org/TR/NOTE-datetime For example, try this... "2018-02-20T11:30:00Z" Note that it must be a capital 'Z', not a lowercase 'z'. Apple does not support the lowercase form.
  2. Hans Knöchel 2018-05-05

    Resolving as per previous comments - it is nothing Titanium influences. In case the old behavior should be restored (it was during a major release which expects API's to change in behavior), guidance is given above.
  3. Abir Mukherjee 2018-05-16

    Closing as ticket was resolved (and not Titanium related)

JSON Source