my $date = shift;
# Probably an accidental entry like '0212' instead of '2012',
- # but 1) the leading 0 gets stripped in CStoreEditor and
+ # but 1) the leading 0 may get stripped in cstore and
# 2) DateTime::Format::ISO8601 returns an error as years
# must be 2 or 4 digits
if ($date =~ m/^\d{3}-/) {
util.date.check_past = function(format,date) {
if (format != 'YYYY-MM-DD') { throw('I only understand YYYY-MM-DD. Fix me if you want.'); }
- var yyyy = date.substr(0,4); var mm = date.substr(5,2); var dd = date.substr(8,2);
+ var yyyy = date.substr(0,4);
+ var mm = date.substr(5,2);
+ var dd = date.substr(8,2);
var test_date = new Date( yyyy, mm - 1, dd );
+
+ /* Ensure our date is valid */
+ if (isNaN(test_date.getTime())) {
+ throw('The date "' + date + '" is not valid.');
+ }
+
date = util.date.formatted_date(new Date(),'%F');
yyyy = date.substr(0,4); mm = date.substr(5,2); dd = date.substr(8,2);
var today = new Date( yyyy, mm - 1, dd );
['change'],
function(ev) {
try {
- document.getElementById('checkout_duedate_checkbox').checked = true;
+ document.getElementById('checkout_duedate_checkbox').checked = true;
if (obj.check_date(ev.target)) {
ev.target.parentNode.setAttribute('style','');
} else {
obj.controller.view.checkout_barcode_entry_textbox.disabled = false;
obj.controller.view.cmd_checkout_submit.setAttribute('disabled','false');
obj.controller.view.cmd_checkout_submit.disabled = false;
- if (util.date.check_past('YYYY-MM-DD',node.value) ) {
- obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
- obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
- return false;
+ try {
+ if (util.date.check_past('YYYY-MM-DD',node.value) ) {
+ obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
+ obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
+ return false;
+ }
+ }
+ catch (E) {
+ obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
+ obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
+ return false;
}
return true;
} catch(E) {