kendo.parseDate to calculate offset fails in few devices

4 posts, 0 answers
  1. Julien
    Julien avatar
    2 posts
    Member since:
    Oct 2013

    Posted 04 May Link to this post

    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

  2. Stefan
    Admin
    Stefan avatar
    1040 posts

    Posted 09 May Link to this post

    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.
  3. Julien
    Julien avatar
    2 posts
    Member since:
    Oct 2013

    Posted 09 May in reply to Stefan Link to this post

    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

  4. Stefan
    Admin
    Stefan avatar
    1040 posts

    Posted 12 May Link to this post

    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.
Back to Top