Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add util round time to quarter hour for futuretime

Ed Plato38f2b0363e10
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 7dcc2d4f0..e61cc5289 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -367,6 +367,24 @@ export default (function(self) {
timeToReturn.setMinutes(Math.round(timeToReturn.getMinutes()));
return timeToReturn;
};
+
+ /**
+ * Round input time to quarter hour
+ *
+ * @method roundTimeQuarterHour
+ * @static
+ * @param time {Date} date
+ * @return {number} rounded date
+ */
+ self.roundTimeQuarterHour = function(time) {
+ const timeToReturn = new Date(time);
+
+ timeToReturn.setMilliseconds(Math.round(timeToReturn.getMilliseconds() / 1000) * 1000);
+ timeToReturn.setSeconds(Math.round(timeToReturn.getSeconds() / 60) * 60);
+ timeToReturn.setMinutes(Math.round(timeToReturn.getMinutes() / 15) * 15);
+ return timeToReturn;
+ };
+
/**
* Remove spaces and combine value
*