In my angular project, I have the following code. It works perfectly fine in Chrome and Firefox, but in Safari, it throws an exception.
var shour = "9:00:00 PM CDT";
var ehour = "12:00:00 AM CDT";
var conver_shour = shour.match(/^(\d+):(\d+)/)[0] + shour.match(/[AP][M]$/)[0];
var conver_ehour = ehour.match(/^(\d+):(\d+)/)[0] + ehour.match(/[AP][M]$/)[0];
console.log("shour: " + conver_shour); // The expected result is 09:00PM
console.log("ehour: " + conver_ehour); // The expected result is 12:00AM
I attempted to run this on jsbin, plunkr, and jsfiddle, but encountered a failure without being able to determine the cause.
This is the exception: Error: null is not an object (evaluating 'shour.match(/[AP][M]$/)') $eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js:142:467 $apply@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js:143:193 https://cdnjs.cloudflare.com/ajax/libs/angular-ui-calendar/1.0.0/calendar.min.js:1:326 https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js:156:171
Any assistance would be greatly appreciated. Thank you.