jquery-calendrical
jquery-calendrical copied to clipboard
Time range end_time is improper
I am using this in my ROR code, I am using this to set opening and closing timings for shop. default time I show to user is 10:30 AM as start_time and 11:30 PM as end_time for 7 days, I am running a loop and in it I am setting these values in text fields, issue is when i click over end_time then I get drop down of timing from start time i.e 10:30 AM till 1:00 PM with correct diffrance with start_time, but it should show my default time 11:30 PM as end_time.
javascript is $(document).ready(function() { for(var i = 0; i < 7; i++) { $("#time_start"+i+", #time_end"+i).calendricalTimeRange(); } });
<% ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'].each_with_index do |wd, index| %> <%= text_field_tag "shop_timings_attribute[start_time][]", "08:30AM",:readonly => "readonly",:id => "time_start#{index}" %> to <%= text_field_tag "shop_timings_attribute[end_time][]", "11:30PM",:readonly => "readonly",:id => "time_end#{index}" %> <% end >
Hi I figured out the issue. In jquery.calendrical.js, in line number 101 actual code was if (match[3] && match[3].toLowerCase() == 'PM') hour += 12; I changed it to if (match[3] && match[3].toLowerCase() == 'pm') hour += 12; because at line 96, variable match is evaluated as var match = match = /(\d+)\s_[:-.,]\s_(\d+)\s*(AM|PM)?/i.exec(text); so match[3] will contain either 'AM' or 'PM' so toLowerCase() will convert it to lower case string and you was comparing it with Upper case string.