Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #30 from ndbroadbent/patch-1

Fixed bug with 2-digit hours. "10:00 AM" was being parsed as "1:00 AM".
  • Loading branch information...
commit 83532854ea14c46914b5c81b06d29f43f1f521a5 2 parents 281890a + 9de2055
@timcharper authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 public/javascripts/calendar_date_select/format_american.js
View
10 public/javascripts/calendar_date_select/format_american.js
@@ -15,20 +15,20 @@ Date.parseFormattedString = function (string) {
// 11/1/1111 01pm
// 1/1/1111 01:11pm
// 1/1/1111 1:11pm
- var regexp = "(([0-1]?[0-9])\/[0-3]?[0-9]\/[0-9]{4}) *([0-9]{1,2}(:[0-9]{2})? *(am|pm))?";
+ var regexp = "(([0-1]?[0-9])\/[0-3]?[0-9]\/[0-9]{4}) *(([0-9]{1,2})(:[0-9]{2})? *(am|pm))?";
string = string.strip();
var d = string.match(new RegExp(regexp, "i"));
if (d==null) {
return Date.parse(string); // Give javascript a chance to parse it.
}
-
+
mdy = d[1].split('/');
hrs = 0;
mts = 0;
if(d[3] != null && d[3].strip() != "") {
- hrs = parseInt(d[3].split('')[0], 10);
- if(d[5].toLowerCase() == 'pm') { hrs += 12; } // Add 12 more to hrs
- mts = d[4].split(':')[1];
+ hrs = parseInt(d[3], 10);
+ if(d[6].toLowerCase() == 'pm') { hrs += 12; } // Add 12 more to hrs
+ mts = d[5].split(':')[1];
}
return new Date(mdy[2], parseInt(mdy[0], 10)-1, mdy[1], hrs, mts, 0);
Please sign in to comment.
Something went wrong with that request. Please try again.