[AC-2528] Creating an allday event on Android shifts the day back by one on device
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-07-28T17:28:43.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Stefan Schüller |
Assignee | Mauro Parra-Miranda |
Created | 2013-08-30T09:39:35.000+0000 |
Updated | 2016-03-08T07:41:35.000+0000 |
Description
When creating an allday event the day is not entered into the devices calendar on the correct day. When setting allday to false the event is added at the correct time points.
Test Case:
var t = ('2013-08-04 00:00:00').split(/[- :]/);
var start = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
var t = ('2013-08-04 23:59:59').split(/[- :]/);
var end = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]);
Ti.API.info('start: '+start);
Ti.API.info('end: '+end);
var CALENDAR_TO_USE = 1;
var defCalendar = Ti.Calendar.getCalendarById(CALENDAR_TO_USE);
defCalendar.createEvent({
title: 'test',
notes: 'notes',
location: 'Some address',
begin: start,
end: end,
allDay: true
});
Console will print:
start: Sun Aug 04 2013 00:00:00 GMT+0200 (CEST)
end: Sun Aug 04 2013 23:59:59 GMT+0200 (CEST)
But the event is added to August 3rd on the device.
Attachments
File | Date | Size |
---|---|---|
device-2013-08-30-113837.png | 2013-08-30T09:39:35.000+0000 | 680488 |
device-2013-09-19-165812.png | 2013-09-19T14:59:04.000+0000 | 96515 |
Hi Stefan Schüller, Your code is incomplete could you provide runnable code so that i can past into the app.js file and reproduce this issue. And you can also follow [this link](http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Calendar) Thanks,
The code I posted is exactly what I have in my app.js. The app will show the splash and do nothing other than this so you need to force close it. I found the Problem in another app but I can not post it, this is why I create this app as a test. Exact Process:
Start monitor from android SDK
Connect Android phone
In Titanium Run on Android Device
App launches with splash screen
Observe log output on monitor
Close app and check calendar on device.
Thanks, StefanHi Motiur, Here is a version with a window and a button. It will print what it wanted to do into the two labels. When you check the phone calendar you will see it added it to the wrong day.
Let me know if you need anything else. Thanks, Stefan
Hi Stefan Schüller, I have tested your code, you just split the date and time then show it in console and label and it occurs perfectly but you said that allday event the day is not entered into the devices calendar on the correct day, i don't reproduce this issue. You can follow [this link](http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Calendar) and try to solve it. Then know me. Thanks,
Hi Motiur, I still doesn't work for me (even on the latest SDK 3.1.3). I adjusted my test code to use the almost exact same code as the example in the documentation:
It is still off by one day. The event should be added to August 4th but is added to August 3rd on the devices calendar. This is on a Samsung Galaxy S3 (GT-I9300), Android 4.1.2.
@Stefan - Thanks for sending us your code. We will test it ASAP and post an update for you.
Hi Stefan, I was unable to reproduce this issue on our Galaxy S2 and Galaxy S3 devices. This could be a timezone issue. According to the documentation for Date(): "The JavaScript Date object provides uniform behavior across platforms. The time value can be passed between systems to represent the same moment in time and if used to create a local date object, will reflect the local equivalent of the time. The JavaScript Date object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed." It looks like your device is in the CEST GMT+0200 timezone, could you please verify what timezone your device is set to? You could also consider setting the calendar event to start several hours later in the day to see if the event is then on the correct day, as a test. If that is the case, you may need to modify your code to account for different timezones.
The timezone on the device is GMT +2. Setting eventBegins hours to 02 works but I don't understand why setting a non all day event works correctly placing the item at the correct time and a fullday event does not. Adding a non allday event correctly I need to do this:
For an allday event I need to do this (makes no sense that the timezone is checked here but not above):
Just FYI, in iOS I do not need to account for the GMT offset. This code works fine on an iOS device with GMT +2 but does not work on an Android device with GMT +2
I have also run into this issue and setting all day events to a day past to account for our -5:00 or -06:00 timezone offset. This only occurs on Android on allday events that are longer than one day. My only major difference between the code above is I'm using the bundled moment.js that is included with alloy to create the dates. Ti 3.2.2.GA Nexus 7 - 4.4.2 Samsung Galaxy S3 - 4.3 Moto Droid Razor HD - 4.1.2 Moto Droid Razr - 2.3.7
Fixed in 3.3.0.GA. Tested with Moto X with Android 4.4.2.