This is a migrated thread and some comments may be shown as answers.

kendo.parseDate to calculate offset fails in few devices

3 Answers 61 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Julien
Top achievements
Rank 1
Julien asked on 04 May 2017, 01:53 PM

Hello,

I am using kendo.parseDate to calculate the offset time of day, as my database does not use UTC and also because I want to show the time of a given time zone where my events are taking place. It works as expected in vast majority of devices but I have a couple of users with at least one on Android 6 for which the code below does not work. Any ideas or suggestions?

01.function offsetScheduleTime(t){
02.    var oStr = kendo.toString(kendo.parseDate(t), "HH:mmzzz"); //reads 13:00+02:00
03.    if (oStr !== undefined && oStr.length == 11) {
04.        var oOffHour = parseInt(oStr.substr(5, 2));
05.        var d = new Date(t);
06.        var res = new Date(d.setHours(d.getHours() + oOffHour));
07.        return kendo.toString(res, "HH:mm");
08.    }
09.    else {
10.        return kendo.toString(kendo.parseDate(t), "HH:mm");
11.    }  
12.}

 

Thanks a lot for your help.

Julien

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 09 May 2017, 11:38 AM
Hello Julien,

I was not able to reproduce the issue using an Android phone with version 6.*.

I just want to clarify the expected result. For example, I`m passing a date and the kendo.parseDate have to parse it and display only the time without the offset?

If that is correct, please send a fully runnable example, to ensure that all of the formats are the same, and the model and the specific Android version, and I will gladly assist.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Julien
Top achievements
Rank 1
answered on 09 May 2017, 03:36 PM

Hi Stefan,

Thanks a lot for your reply. For the clarification, I would like, as result, the time with the offset. For instance, passing 2017-05-09T14:54:00 in Western Europe time (GMT +2) should output: 16:54.

Concerning the Android version, I was able to look at two user's phone. The first one is running Android 6.0.1; Baseband version: G925FXXU5DPL3; Kernel version: 3.10.61-8821257. The second one runs on Android 7.0; Baseband verion: G935FXXU1DQD7; Kernel version: 3.18.14-11104523.

You can see a live example here: http://www.brsmeas.org/DNN/TestPages/Juliendailyscheduletest/tabid/5829/language/en-US/Default.aspx, using Kendo core, not mobile...

Thanks a lot, for your kind support.

Julien

0
Stefan
Telerik team
answered on 12 May 2017, 08:35 AM
Hello Julien,

Thank you for the example.

I was able to observe different results on my end on different devices. And the issue is that based on the device culture the length of oStr is not 11, which is causing the logic to go in the else statement.

Still, as the logic is complex, could you please advise what is the desired end result?

As if the date have to be displayed in the user time zone, this line will correctly convert it:

new Date(t)


Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Julien
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Julien
Top achievements
Rank 1
Share this question
or