jQuery UI Widgets › Forums › Plugins › Data Adapter › Wrong date generated from local data in Firefox
Tagged: dataadapter, date, Firefox
This topic contains 9 replies, has 3 voices, and was last updated by admin 4 years, 5 months ago.
-
Author
-
Hey Team
Seems like dataAdapter have some problems to generate proper data in Firefox.
I am creating new dataAdapter from following source:
{ "datatype": "json", "datafields": [ { "name": "_id", "type": "string" }, { "name": "parent_job", "type": "string" }, { "name": "task_name", "type": "string" }, { "name": "start_date", "type": "date" }, { "name": "end_time", "type": "date" } ], "hierarchy": { "keyDataField": { "name": "_id" }, "parentDataField": { "name": "parent_job" } }, "id": "_id", "sortcolumn": "end_time", "sortdirection": "desc", "localdata": [] }
localdata contains among others following data:
{ "parent_job": "TEST", "_id": "1111", "task_name": "Test Task", "start_date": "8/3/2020, 11:48:40.582 AM", "end_time": "9/9/3000, 12:00:00.0 AM" }
The problem is for: “end_time”: “9/9/3000, 12:00:00.0 AM”.
If I create new new $.jqx.dataAdapter this is what I get for this field in Firefox:
loadedData:{ "parent_job": "TEST", "_id": "1111", "task_name": "Test Task", "start_date": "8/3/2020, 11:48:40.582 AM", "end_time": "9/9/3000, 12:00:00.0 AM" }
originaldata:
{ "_id": "1111", "parent_job": "TEST", "task_name": "Test Task", "start_date": "2020-08-04T09:48:40.587Z", "end_time": "2020-08-04T10:00:00.000Z", "uid": "1111" }
records:
{ "_id": "1111", "parent_job": "TEST", "task_name": "Test Task", "start_date": "2020-08-04T09:48:40.587Z", "end_time": "2020-08-04T10:00:00.000Z", "uid": "1111" }
What is going on here? Why my end date is not generated properly?
I have spent multiple hours to figure this out but with no luck.
All the other browsers works fine except Firefox.Please take a look on this and send me some feedback as soon as possible as this is rather critical issue for us as this ‘end_time’ future date is a base for us to some heavy business logic!
BR
Tomasz KapalkaOK I have prepared fiddle snippet to show the problem:
https://jsfiddle.net/kapalkat/txueL17h/8/Please open it first in Chrome and you will see correct date generated for end_time and later please open this in Firefox and you will see wrong date generated for the end_time field (current time is generated).
Hello kapalkat,
If you could remove the comma “,” symbol from the format of the date it will work fine.
Meanwhile, I will create a work item for this case.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comHey Hristo
Thanks for your feedback. Indeed it is working fine. However the fiddle was just an example. In production the data is coming from build in function ‘toLocaleString()’:
var defaultDate = new Date(value); var locale = defaultDate.toLocaleString();
So I would need to parse it and remove the comma.
What do you think; how long it can take to have this resolved on your side?BR
Tomasz KapalkaHello Tomasz Kapalka,
We cannot engage with a deadline when this will be done because we work on different tasks with different priorities.
Meanwhile, you could try this approach below:var source = { "datatype": "json", "datafields": [ { "name": "_id", "type": "string" }, { "name": "parent_job", "type": "string" }, { "name": "task_name", "type": "string" }, { "name": "start_date", "type": "date" }, { "name": "end_time", "type": "date" } ], "hierarchy": { "keyDataField": { "name": "_id" }, "parentDataField": { "name": "parent_job" } }, "id": "_id", "sortcolumn": "end_time", "sortdirection": "desc", "localdata": [ { "parent_job": "TEST", "_id": "1111", "task_name": "Test Task", "start_date": "8/3/2020, 11:48:40.582 AM", "end_time": "9/9/3000, 12:00:00.0 AM" } ], beforeprocessing: function (records) { records[0].end_time = records[0].end_time.replace(",", ""); return records; } }; var dataAdapter = new $.jqx.dataAdapter(source); dataAdapter.dataBind(); console.log(dataAdapter.records[0].end_time);
I hope this will help.
Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comHey Hristo
I assume that all date related records are affected in Firefox…? Why would only (‘September 9, 3000’) be broken?:)
So I would need to look for every ‘date’ record beforeprocerssing.
This is not a very good idea as date record is a string here…so I would need to search it for date ‘looking’ data.
Sounds ugly to me:)
Is there any way to pin this topic to some official jQWidgets bug that I could track it?BR
TKHello Tomasz,
It is only a suggestion you could use it to handle all records in your source.
About the issue, you could check the progress on this page.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comHey @hristo
I have applied the workaround and it occurred, it’s generating wrong date in Firefox.
Please check this out in Firefox:
https://jsfiddle.net/kapalkat/vmcgfL18/3/
TEST1 end_date is: ‘9/2/2020, 10:50:00.0 AM’
and when I apply:beforeprocessing: function (records) { if (navigator.userAgent.toLowerCase().indexOf('firefox') !== -1){ records.forEach(function (record) { if (record.end_time) { record.end_time = record.end_time.replace(',', ''); } }) } return records; },
I get ‘Sun Feb 09 2020 10:50:00 GMT+0100 (Central European Standard Time)’ instead ‘Wed Sep 02 2020 10:50:00 GMT+0200 (Central European Summer Time)’ (Chrome)
We haven’t noticed that as we were using ‘9/9/3000, 12:00:00.0 AM’ for previous test (date and month are the same here).I have no idea what’s inside your lib as it’s minimized and thus really hard to read! Could you please help me here to get the correct dates in Firefox?
Someone has just closed the ticket connected to this issue but I have added a comment with information why this should be still open and corrected:
https://github.com/jqwidgets/jQWidgets/issues/309Missing Javascript code in initialization:
{ "name": "end_time", "type": "date", format: 'dd/MM/yyyy, hh:mm:ss.z tt' }
-
AuthorPosts
You must be logged in to reply to this topic.