Wrong date value selected from calendar using Firefox/IE
This custom app was developed using WebIDE. Now I have deployed the app locally to the customer system and while testing it using different browsers I noticed a strange bug when using Firefox or IE11:
I have a calendar view which retrieves infotype 2001 and 2002 entries from the backend for the selected date. When I select a date in the calendar, the app fetches time entries for the previous day instead of the selected day:
The browser debugger shows that it sends the GET command with wrong date values to the backend:
So, somewhere between the click and the formation of the URI the date value gets corrupted. This happens systematically for all dates, and it's always 1 day off.
But when using Chrome (and Chrome portable) the calendar selection works just fine! It fetches the correct day.
Also the WebIDE version behaves the same way, so it's not related to the code migration.
Since the users are mostly using IE and Firefox, this needs a remedy, so I'm asking you experts for help.
The customer system is having SAPUI5 runtime 1.28.5. And I think WebIDE is having 1.28.9.
Thanks for any help or tips!
thanh vu duy replied
I think that is when you use the .filter for the binding items in the table, the system auto convert the filter time value from browser's time zone to GMT+0 time value.
You should change from "T00:00:00" to your's TimeZoneOffset
The browser has a method to get TimeZoneOffset:
var TZOffsetMs = new Date();
TZOffsetMs = - TZOffsetMs.getTimezoneOffset();
timeZoneMs = TZOffsetMs % 60;
timeZoneHs = ( TZOffsetMs - TZOffsetMs % 60 ) / 60 ;
if (timeZoneHs < 10) timeZoneHs = "0" + timeZoneHs ;
if (timeZoneMs < 10) timeZoneMs = "00";
oControlEvent.mParameters.date.substring(8, 10) + "T00:00:00" "T"+ timeZoneHs + ":" + timeZoneMs + ":00";