From c6ab38a51da51387293321fd4f6cf29ee2ff6a92 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 11 Apr 2016 21:28:10 +0000 Subject: [PATCH] Fix set_min/set_max with a full string timestamp caused a formatting error --- api/js/etemplate/et2_widget_date.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/api/js/etemplate/et2_widget_date.js b/api/js/etemplate/et2_widget_date.js index 6767aad6d9..081f4bd63b 100644 --- a/api/js/etemplate/et2_widget_date.js +++ b/api/js/etemplate/et2_widget_date.js @@ -362,6 +362,17 @@ String: A string in the user\'s date format, or a relative date. Relative dates } else { + // Check for full timestamp + if(typeof _value == 'string' && _value.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(?:\.\d{3})?(?:Z|[+-](\d{2})\:(\d{2}))/)) + { + _value = new Date(_value); + // Add timezone offset back in, or formatDate will lose those hours + var formatDate = new Date(_value + this.date.getTimezoneOffset() * 60 * 1000); + if(this._type == 'date') + { + _value = jQuery.datepicker.formatDate(this.dateFormat, formatDate); + } + } this.input_date.datepicker('option','minDate',_value); } } @@ -405,6 +416,17 @@ String: A string in the user\'s date format, or a relative date. Relative dates } else { + // Check for full timestamp + if(typeof _value == 'string' && _value.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})(?:\.\d{3})?(?:Z|[+-](\d{2})\:(\d{2}))/)) + { + _value = new Date(_value); + // Add timezone offset back in, or formatDate will lose those hours + var formatDate = new Date(_value + this.date.getTimezoneOffset() * 60 * 1000); + if(this._type == 'date') + { + _value = jQuery.datepicker.formatDate(this.dateFormat, formatDate); + } + } this.input_date.datepicker('option','maxDate',_value); } }