Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fixed regression where code was not assuming that invalid dates throw an exception

Mike McGann3738714d5c17
diff --git a/js/Worldview/Widget/WorldviewMap.js b/js/Worldview/Widget/WorldviewMap.js
index 4083bd1f6..95141c4b4 100644
--- a/js/Worldview/Widget/WorldviewMap.js
+++ b/js/Worldview/Widget/WorldviewMap.js
@@ -94,10 +94,12 @@ Worldview.Widget.WorldviewMap = function(containerId, config) {
if ( state.time === undefined ) {
state.time = today.toISOStringDate();
}
- var date = Date.parseISOString(state.time);
- if ( isNaN(date.getTime()) ) {
- log.warn("Invalid time: " + state.time +
- ", using today: " + today.toISOStringDate());
+ var date;
+ try {
+ date = Date.parseISOString(state.time);
+ } catch ( error ) {
+ log.warn("Invalid time: " + state.time + ", reason: " +
+ error + "; using today: " + today.toISOStringDate());
state.time = today.toISOStringDate();
date = today;
}
diff --git a/js/dateSpan.js b/js/dateSpan.js
index 911f6326c..0952fa1e2 100644
--- a/js/dateSpan.js
+++ b/js/dateSpan.js
@@ -471,11 +471,13 @@ SOTE.widget.DateSpan.prototype.showSliders = function(){
*
*/
SOTE.widget.DateSpan.prototype.setValue = function(value){
- var d = value ? Date.parseISOString(value)
- : this.getToday();
- // Check to see if the date is valid, if not default to today
- if (isNaN(d.getTime())) {
- this.log.warn("Invalid time: " + value + ", using today");
+ var d;
+ try {
+ var d = value ? Date.parseISOString(value)
+ : this.getToday();
+ } catch ( error ) {
+ this.log.warn("Invalid time: " + value + ", reason: " + error +
+ "; using today");
d = Worldview.today();
}