cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong date value selected from calendar using Firefox/IE

omakinen
Participant
0 Kudos

Hi all!

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:

GET zxyListSet?$skip=0&$top=20&$filter=Begda%20eq%20datetime%272015-07-14T21%3a00%3a00%27%20and%20Endda%20eq%20datetime%272015-07-14T21%3a00%3a00%27%20and%20substringof(%123456789%27,Pernr)&$inlinecount=allpages

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!

br,

Ossi M

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ossi.

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();

     var timeZoneHs;

     var timeZoneMs;

     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";

Answers (3)

Answers (3)

omakinen
Participant
0 Kudos

I have been painfully debugging the code and I have gotten closer to where the formation of filter value goes wrong.

So, I select the day 2015-07-15 in the calendar.....

In the Details.controller.js I have the function to catch the date selection:


_onTapOnDate: function

var vSelectMonth = new Date(Date.parse(oControlEvent.mParameters.date.substring(4, 7) + " " + oControlEvent.mParameters.date.substring(8, 10) + " ," + oControlEvent.mParameters.date.substring(11, 15))).getMonth() + 1;

if (vSelectMonth < 10) vSelectMonth = "0" + vSelectMonth;var vSelectDate = oControlEvent.mParameters.date.substring(11, 15) + "-" + vSelectMonth + "-" + oControlEvent.mParameters.date.substring(8, 10) + "T00:00:00";

        var sPernr = sap.ui.getCore().getModel("pernr");

        var oFilterPernr = new sap.ui.model.Filter("Pernr",

sap.ui.model.FilterOperator.Contains, sPernr);

        var sBegda = vSelectDate;

        var oFilterBegda = new sap.ui.model.Filter("Begda",

sap.ui.model.FilterOperator.EQ, sBegda);

        var sEndda = vSelectDate;

        var oFilterEndda = new sap.ui.model.Filter("Endda",

sap.ui.model.FilterOperator.EQ, sEndda);

        var oBinding = this.byId("navigationTable").getBinding("items");

        oBinding.filter([oFilterBegda, oFilterEndda, oFilterPernr]);

    },

Here everything is still correct (dates are 2015-07-15):

vSelectDate

"2015-07-15T00:00:00"

sPernr

"xxxxxxxx"

sBegda

"2015-07-15T00:00:00"

oFilterBegda

Object { sPath="Begda", sOperator="EQ", oValue1="2015-07-15T00:00:00", more...}

sEndda

"2015-07-15T00:00:00"


Then in the last line:

    oBinding.filter([oFilterBegda, oFilterEndda, oFilterPernr]);


it goes deep to create the sFilterParams :

The function ODataUtils._createFilterParams is in

/resources/sap/ui/model/odata/ODataUtils-dbg.js

JS Bin - Collaborative JavaScript Debugging

...and coming back from here the value in sFilterParams is one day off (=2015-07-14).

I.e. when I selected 15.7.2015 it brings back this filter value:

"$filter=Begda%20eq%20datetime%272015-07-14T21%3a00%3a00%27%20and%20Endda%20eq%20datetime%272015-07-14T21%3a00%3a00%27%20and%20substringof(%27xxxxxxx%27,Pernr)"

And this is used to get the values from oData model to the screen based on the selected day.

Funnily the filter values are present in multiple variables, and in these the days remain correct (=2015-07-15):

This is from the ODataUtils._createFilterParams again:


function(aFilters, oMetadata, oEntityType)

[Object { sPath="Begda", sOperator="EQ", oValue1="2015-07-15T00:00:00", more...}, Object { sPath="Endda", sOperator="EQ", oValue1="2015-07-15T00:00:00", more...}, Object { sPath="Pernr", sOperator="Contains", oValue1="xxxxxxxx", more...}]

Object { sPath="Begda", sOperator="EQ", oValue1="2015-07-15T00:00:00", more...}

Object { sPath="Endda", sOperator="EQ", oValue1="2015-07-15T00:00:00", more...}

Object { sPath="Pernr", sOperator="Contains", oValue1="xxxxx", more...}

All this code where it forms the filters is SAP standard (coming from the WebIDE) so I don't know what I could do to fix it. And I doubt the core functions would be really that buggy... it's not impossible but I guess many others would have noticed the same too.

Any pointers where to look at? Is there anything else that I can share which would help?

omakinen
Participant
0 Kudos

Hi Santhosh!

I'm not sure you what you mean by "you are trunk the time"?

Anyway, has anyone found out a fix or workaround for this bug?

santhu_gowdaz
Active Contributor
0 Kudos

means you are consider only the date and not the time.while getting the date use "DataTime" instead of "Date". i'm not sure this will solve your issue.just a guess.

omakinen
Participant
0 Kudos

Hi!

I'd like to provide some more information in case someone has an idea....

In the Details.controller.js the date selection is coded like this:

_onTapOnDate: function(oControlEvent) {

  var vSelectMonth = new Date(Date.parse(oControlEvent.mParameters.date.substring(4, 7) + " " + oControlEvent.mParameters.date.substring(8, 10) + " ," + oControlEvent.mParameters.date.substring(11, 15))).getMonth() + 1;

  if (vSelectMonth < 10) vSelectMonth = "0" + vSelectMonth;

  var vSelectDate = oControlEvent.mParameters.date.substring(11, 15) + "-" + vSelectMonth + "-" + oControlEvent.mParameters.date.substring(8, 10) + "T00:00:00";

  var sPernr = sap.ui.getCore().getModel("pernr");

  var oFilterPernr = new sap.ui.model.Filter("Pernr", sap.ui.model.FilterOperator.Contains, sPernr);

  var sBegda = vSelectDate;

  var oFilterBegda = new sap.ui.model.Filter("Begda", sap.ui.model.FilterOperator.EQ, sBegda);

  var sEndda = vSelectDate;

  var oFilterEndda = new sap.ui.model.Filter("Endda", sap.ui.model.FilterOperator.EQ, sEndda);

  var oBinding = this.byId("navigationTable").getBinding("items");

  oBinding.filter([oFilterBegda, oFilterEndda, oFilterPernr]);

  },

santhu_gowdaz
Active Contributor
0 Kudos

i too face this problem. problem is in those browser's reading the date with time like "14.07.2015 22.00.00"

it means 15.07.2015 but may be you are trunk the time. that's the reason for this.