[TIMOB-13659] iOS: Date() value gets changed when passed via events
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.1.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | reprod |
Reporter | Joel Margolese |
Assignee | Unknown |
Created | 2013-04-23T18:39:20.000+0000 |
Updated | 2018-02-28T20:03:23.000+0000 |
Description
*Problem description*
I have built a simple Alloy test case that passes a date object between two controllers by firing Ti.App.fireEvent. Tested in iOS 6.1 simulator on Mountain Lion. Titantium 3.1.0.GA. But this occurs with 3.0.2.GA as well.
*Test case*
function buttonClick() {
var time = new Date('4/21/2013 11:45 am');
var argInfo = {
eventTime : time
};
Ti.API.info('starting time: ' + JSON.stringify(argInfo));
Ti.App.fireEvent("testEvent", argInfo);
}
Ti.App.addEventListener('testEvent', function(info) {
Ti.API.info(" in event time: " + info.eventTime.toString());
});
var win = Ti.UI.createWindow({
backgroundColor : "#FFF"
});
var button = Titanium.UI.createButton({
title : 'Fire Event',
top : 10,
width : 100,
height : 50
});
button.addEventListener('click', buttonClick);
win.add(button);
win.open();
*Console output*
[INFO] starting time: {"eventTime":"2013-04-21T15:45:00.000Z"}
[INFO] in event time: Sun Apr 21 2013 11:46:02 GMT-0400 (EDT)
*Note*
The time prior to firing the event is 15:45, but when it arrives the minutes are now: 46.02
I presume this is a problem with the serializing of the date object.
Perhaps Data() objects are not legal for events, but they used to work, this is old code that has now stopped working.
If they are not legal, Titanium should throw an error or it should be documented.
*Workaround*
Pass the date as:
newDate().toString()
Attachments
File | Date | Size |
---|---|---|
test.zip | 2013-04-23T18:42:08.000+0000 | 8914514 |
deleted build folder, not sure why, but it was 90MB.
Tested and sort of confirmed on iOS 6 simulator, Ti SDK 3.1 GA. This is the output I get:
So there's about 10 seconds difference here...
I am able to reproduce this issue with the following environment; iPhone 6 (10.0) Studio 4.9.0.201705302345 Ti SDK 6.1.1 GA Appc NPM 4.2.9 Appc CLI 6.2.2 Ti CLI 5.0.14 Alloy 1.9.11 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131