Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time range end_time is improper #17

Open
swapnilchincholkar opened this issue Nov 21, 2011 · 1 comment
Open

Time range end_time is improper #17

swapnilchincholkar opened this issue Nov 21, 2011 · 1 comment

Comments

@swapnilchincholkar
Copy link

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 >

@swapnilchincholkar
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant