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

[Solved] Bug with Time Picker when day only has 23 hours

3 Answers 26 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel
Top achievements
Rank 1
Daniel asked on 12 Mar 2012, 11:10 AM
Hi

With the clocks moving forward due to daylight savings at the end of the month i decided to carry out a few checks to see if the website i support would encounter any problems. I have searched for any info on this but so far have not found any.

I noticed that if the server its hosted on only has 23 hours, then the timepicker gets confused and all of the displayed times are displayed with midnight as the hours. So with the interval set at 15mins, you would only see 00:00, 00:15, 00:30, 00:45 repeated in the list instead of incrementing the hours.

My questions are thus, if this is a known issue, is there a workaround to use? Is there any plans to fix this bug in an upcoming release?

Thank you

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 Mar 2012, 12:13 PM
Hello Daniel,

 
Thank you for drawing our attention to this issue. We were able to address the problem and the fixed JS files are attached to this message. As a gratitude for your involvement I have updated your Telerik points.

Kind regards,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Daniel
Top achievements
Rank 1
answered on 13 Mar 2012, 02:37 PM
Hi Georgi

Cheers for the fix, im assuming those are modified files of the latest version? Currently the site is using the 2011.2 712 version of the mvc controls. Would it be possible to get an updated version of those files? If not, would it be possible to find out what changes where made to fix the problem and i can go edit the files.
0
Accepted
Georgi Krustev
Telerik team
answered on 14 Mar 2012, 11:19 AM
Hello Daniel,

It seams that the provided JS files does not fix the issue completely. I attached the new files to this messages. 

Your assumption is correct. The files are from the latest version. In general we do not update older version in order to fix the problem. In order to apply the fixes manually you will need to modify these files:

[telerik.common.js]

$.extend($t.datetime, {
        //modify
        add: function (date, valueToAdd, ignoreDST) {
            var tzOffsetBefore = date.timeOffset();
            var resultDate = new $t.datetime(date.time() + valueToAdd);
            var tzOffsetDiff = resultDate.timeOffset() - tzOffsetBefore;
 
            if (ignoreDST) {
                return resultDate;
            }
 
            return new $t.datetime(resultDate.time() + tzOffsetDiff * $t.datetime.msPerMinute);
        },
 
        //add
        dst: function () {
            var today = new $t.datetime(),
                midnight = new $t.datetime(today.year(), today.month(), today.date(), 0, 0, 0),
                noon = new $t.datetime(today.year(), today.month(), today.date(), 12, 0, 0);
 
            return -1 * (midnight.timeOffset() - noon.timeOffset());
        },
        ....
}

[telerik.timepicker.js]
bind: function () {
            var getTimeMilliseconds = $t.timeView.getTimeMilliseconds;
 
            var availableHours = [];
            var format = this.format;
            var interval = this.interval;
            var tmpDate = new $t.datetime(this.minValue);
            var msMinTime = getTimeMilliseconds(tmpDate);
            var msMaxTime = getTimeMilliseconds(this.maxValue);
            var msInterval = interval * $t.datetime.msPerMinute;
            var dst = $t.datetime.dst() * $t.datetime.msPerMinute;
            var ignoreDST = dst < 0;
 
            if (!ignoreDST) {
                dst = 0;
            }
 
            var records = parseInt(($t.datetime.msPerDay + dst) / (interval * $t.datetime.msPerMinute));
 
            if (msMinTime != msMaxTime) {
                var result = msMinTime < msMaxTime ?
                             msMaxTime - msMinTime :
                             msMaxTime + $t.datetime.msPerDay - msMinTime;
 
                records = parseInt(result / msInterval) + 1;
            }
 
            var add = $t.datetime.add;
            var formater = $t.datetime.format;
            for (var i = 0; i < records; i++) {
                availableHours[i] = formater(tmpDate.toDate(), format);
                tmpDate = add(tmpDate, msInterval, ignoreDST);
            }
 
            if (getTimeMilliseconds(tmpDate) - msInterval - msMaxTime != 0 && msMinTime != msMaxTime && availableHours[records - 1] != formater(this.maxValue, format)) {
                availableHours[records] = formater(this.maxValue, format);
            }
 
            this.dropDown.dataBind(availableHours);
        }
Greetings,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Date/Time Pickers
Asked by
Daniel
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or