Interactive interface for browsing global, full-resolution satellite imagery
date now is 40 minutes ago for geostationary latency
Ed Platob290400ffcd3
diff --git a/e2e/features/share/share-test.js b/e2e/features/share/share-test.jsindex 76bb94287..b5d15826d 100644--- a/e2e/features/share/share-test.js+++ b/e2e/features/share/share-test.js@@ -41,7 +41,8 @@ module.exports = {reuseables.loadAndSkipTour(c, TIME_LIMIT);c.waitForElementVisible(shareToolbarButton, TIME_LIMIT);c.click(shareToolbarButton);- let date = new Date();+ const minutesOffset = 40 * 60000; // 40 minutes+ let date = new Date(new Date().getTime() - minutesOffset);if (date.getUTCHours() < 3) {date = new Date(date.getTime() - 86400000);}diff --git a/web/css/timeline.css b/web/css/timeline.cssindex 1d0146462..179f3052b 100644--- a/web/css/timeline.css+++ b/web/css/timeline.css@@ -438,7 +438,6 @@ button:focus {#current-interval {white-space: nowrap;- padding: 2px 6px;}.timeline-interval,@@ -461,7 +460,7 @@ button:focus {position: absolute;bottom: 100%;border-bottom: 8px solid transparent;- width: 80px;+ min-width: 90px;z-index: 10;}@@ -487,7 +486,7 @@ button:focus {.zoom-btn-active,.interval-btn-active {- width: 80px;+ width: 90px;color: #ccc;font-size: 12px;line-height: 14px;diff --git a/web/js/components/layer/product-picker/search/layer-metadata-detail.js b/web/js/components/layer/product-picker/search/layer-metadata-detail.jsindex f71ffbc7b..41d1fb4be 100644--- a/web/js/components/layer/product-picker/search/layer-metadata-detail.js+++ b/web/js/components/layer/product-picker/search/layer-metadata-detail.js@@ -92,7 +92,7 @@ class LayerMetadataDetail extends React.Component {if (endDate) {endDateId = `${id}-endDate`;layerEndDate = util.parseDate(endDate);- if (layerEndDate <= util.today() && !inactive) {+ if (layerEndDate <= util.now() && !inactive) {layerEndDate = 'Present';} else {layerEndDate = util.coverageDateFormatter('END-DATE', endDate, period);diff --git a/web/js/components/sidebar/events-filter.js b/web/js/components/sidebar/events-filter.jsindex 98b63b222..fe271e367 100644--- a/web/js/components/sidebar/events-filter.js+++ b/web/js/components/sidebar/events-filter.js@@ -78,7 +78,7 @@ function EventFilterModalBody (props) {return msg;};const minDate = new Date('2000-01-01');- const maxDate = new Date();+ const maxDate = util.now();return (<div className="events-filter">diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 39c751bf1..d4ad3b6b5 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -183,7 +183,7 @@ class Timeline extends React.Component {// appNow will not update if set in query string using 'now' parameterif (!nowOverride) {this.checkAndUpdateAppNow = this.checkAndUpdateAppNow.bind(this);- this.appNowUpdateInterval = setInterval(this.checkAndUpdateAppNow, 60000 * 15);+ this.appNowUpdateInterval = setInterval(this.checkAndUpdateAppNow, 60000 * 10);}this.setInitialState();}@@ -222,10 +222,8 @@ class Timeline extends React.Component {}}- // if user adds a subdaily layer (and none were active) adjust the time backwards if needed- // and change the time scale to hourly+ // if user adds a subdaily layer (and none were active) change the time scale to hourlyif (hasSubdailyLayers && !prevProps.hasSubdailyLayers) {- this.moveSelectedDateBackwards();this.changeTimeScale(4);}@@ -864,21 +862,6 @@ class Timeline extends React.Component {});}- /**- * If a user adds a subdaily layer and the current selected time is too recent- * it is likely they will see no layer content. Here we are moving the selected time- * backwards for them to attempt to avoid this scenario- */- moveSelectedDateBackwards() {- const { selectedDate } = this.props;- const fortyMinutes = 40 * 60000;- const now = Date.now();- const isRecent = Math.abs(now - selectedDate.getTime()) < fortyMinutes;- if (isRecent) {- this.onDateChange(now - fortyMinutes);- }- }-/*** @desc update dragger time state* @param {String} date@@ -927,7 +910,7 @@ class Timeline extends React.Component {};ensureCanUpdate().then(() => {- updateAppNow(new Date());+ updateAppNow(util.now());});}@@ -1765,6 +1748,7 @@ const getTimelineEndDateLimit = (state) => {}let timelineEndDateLimit;+ console.log(layerDateRange && layerDateRange.end > appNow);if (layerDateRange && layerDateRange.end > appNow) {const layerDateRangeEndRoundedQuarterHour = util.roundTimeQuarterHour(layerDateRange.end);const appNowRoundedQuarterHour = util.roundTimeQuarterHour(appNow);diff --git a/web/js/fixtures.js b/web/js/fixtures.jsindex 1fc89d287..bf5566edb 100644--- a/web/js/fixtures.js+++ b/web/js/fixtures.js@@ -6,6 +6,7 @@ import { getInitialState as getInitialDateState } from './modules/date/reducers'import { defaultState as initialAnimationState } from './modules/animation/reducers';import { defaultAlertState } from './modules/alerts/reducer';import { getInitialEventsState } from './modules/natural-events/reducers';+import util from './util/util';const fixtures = {red: 'ff0000ff',@@ -209,10 +210,11 @@ fixtures.map = () => ({});fixtures.config = function() {+ const now = util.now();return {- pageLoadTime: new Date(),- initialDate: new Date(),- now: new Date(),+ pageLoadTime: now,+ initialDate: now,+ now,defaults: {projection: 'geographic',startingLayers: [diff --git a/web/js/main.js b/web/js/main.jsindex 9522be9d7..42ba3d302 100644--- a/web/js/main.js+++ b/web/js/main.js@@ -139,8 +139,8 @@ window.onload = () => {config.initialIsMobile = crs.innerWidth <= 768;config.pageLoadTime = parameters.now- ? util.parseDateUTC(parameters.now) || new Date()- : new Date();+ ? util.parseDateUTC(parameters.now) || util.now()+ : util.now();const pageLoadTime = new Date(config.pageLoadTime);diff --git a/web/js/map/natural-events/natural-events.js b/web/js/map/natural-events/natural-events.jsindex 194c56be0..4dabf7e03 100644--- a/web/js/map/natural-events/natural-events.js+++ b/web/js/map/natural-events/natural-events.js@@ -112,7 +112,7 @@ class NaturalEvents extends React.Component {* for today, this may not help.*/if (event.categories[0].title === 'Wildfires' && !isInitialLoad) {- const today = dateFormat(new Date());+ const today = dateFormat(util.now());const yesterday = dateFormat(util.yesterday());if (date !== today || date !== yesterday) {selectDate(util.dateAdd(util.parseDateUTC(date), 'day', 1));diff --git a/web/js/modules/animation/actions.test.js b/web/js/modules/animation/actions.test.jsindex d8a3c0515..6f915eb59 100644--- a/web/js/modules/animation/actions.test.js+++ b/web/js/modules/animation/actions.test.js@@ -70,7 +70,7 @@ describe('Open, play, stop, close and toggle actions', () => {);});describe('Animation Datechange actions', () => {- const now = new Date();+ const now = util.now();const then = util.dateAdd(now, 'day', -7);test(`changeStartDate action returns ${diff --git a/web/js/modules/animation/reducer.test.js b/web/js/modules/animation/reducer.test.jsindex cc153649f..37b118ac3 100644--- a/web/js/modules/animation/reducer.test.js+++ b/web/js/modules/animation/reducer.test.js@@ -3,7 +3,7 @@ import { defaultState, animationReducer } from './reducers';import * as CONSTANTS from './constants';import util from '../../util/util';-const now = new Date();+const now = util.now();const then = util.dateAdd(now, 'day', -7);test('OPEN_ANIMATION action updates active state', () => {diff --git a/web/js/modules/date/actions.test.js b/web/js/modules/date/actions.test.jsindex 6cd1a9a4e..02089808f 100644--- a/web/js/modules/date/actions.test.js+++ b/web/js/modules/date/actions.test.js@@ -16,6 +16,7 @@ import {} from './constants';import fixtures from '../../fixtures';import { addLayer, getLayers } from '../layers/selectors';+import util from '../../util/util';const config = fixtures.config();function getState(layers) {@@ -50,7 +51,7 @@ const middlewares = [thunk];const mockStore = configureMockStore(middlewares);// test variables-const mockDate = new Date();+const mockDate = util.now();const customInterval = 3;const delta = 5;const interval = 3;diff --git a/web/js/modules/date/reducers.test.js b/web/js/modules/date/reducers.test.jsindex 71ed9d678..8b6297e07 100644--- a/web/js/modules/date/reducers.test.js+++ b/web/js/modules/date/reducers.test.js@@ -9,9 +9,10 @@ import {SELECT_DATE,UPDATE_APP_NOW,} from './constants';+import util from '../../util/util';// test variables-const mockDate = new Date();+const mockDate = util.now();const selectedZoom = 2;describe('dateReducer', () => {diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.jsindex 6045593ae..4d36604cb 100644--- a/web/js/modules/layers/selectors.js+++ b/web/js/modules/layers/selectors.js@@ -328,7 +328,7 @@ function forGroup(group, spec = {}, activeLayers, state) {*/export function getFutureLayerEndDate(layer) {const { futureTime } = layer;- const max = new Date();+ const max = util.now();const dateType = futureTime.slice(-1);const dateInterval = futureTime.slice(0, -1);diff --git a/web/js/modules/layers/selectors.test.js b/web/js/modules/layers/selectors.test.jsindex 33158d32a..06629b08c 100644--- a/web/js/modules/layers/selectors.test.js+++ b/web/js/modules/layers/selectors.test.js@@ -194,7 +194,7 @@ test('all layers are visible', () => {expect(layerList).toEqual(['aqua-cr', 'terra-cr', 'aqua-aod', 'terra-aod']);});-// NOTE: Not currently using getLayers to retrive layers that are+// NOTE: Not currently using getLayers to retrieve layers that are// specifically either visible or not visible// test('only visible layers', () => {@@ -383,9 +383,9 @@ test('no date range with static', () => {test('get future layer end date is 5 days after mock current date', () => {const testLayer = { futureTime: '5D' };// current date floored to quarter hour- const currentDate = util.roundTimeQuarterHour(new Date());- // test date to comopare is floored to quarter hour and added 5 days using util- const testDate = util.dateAdd(util.roundTimeQuarterHour(new Date()), 'day', 5);+ const currentDate = util.roundTimeQuarterHour(util.now());+ // test date to compare is floored to quarter hour and added 5 days using util+ const testDate = util.dateAdd(util.roundTimeQuarterHour(util.now()), 'day', 5);const futureEndDate = getFutureLayerEndDate(testLayer);const testDateMinutes = testDate.getUTCMinutes();diff --git a/web/js/modules/natural-events/util.js b/web/js/modules/natural-events/util.jsindex 5f7e51279..4d3da7dcd 100644--- a/web/js/modules/natural-events/util.js+++ b/web/js/modules/natural-events/util.js@@ -161,7 +161,7 @@ export function getDefaultEventDate(event) {let date = new Date(preDate).toISOString().split('T')[0];if (event.geometry.length < 2) return date;const category = event.categories.title || event.categories[0].title;- const today = new Date().toISOString().split('T')[0];+ const today = util.now().toISOString().split('T')[0];// For storms that happened today, get previous dateif (date === today && category === 'Severe Storms') {[date] = new Date(event.geometry[1].date).toISOString().split('T');@@ -171,7 +171,7 @@ export function getDefaultEventDate(event) {/*** Validate whether an event and all it's points/polygons fall within- * the provded projection's maxExtent+ * the provided projection's maxExtent** @param {*} event* @param {*} projdiff --git a/web/js/modules/product-picker/util.js b/web/js/modules/product-picker/util.jsindex 49f44e855..cc70c99ce 100644--- a/web/js/modules/product-picker/util.js+++ b/web/js/modules/product-picker/util.js@@ -1,4 +1,5 @@import safeLocalStorage from '../../util/local-storage';+import util from '../../util/util';const { RECENT_LAYERS } = safeLocalStorage.keys;const MAX_RECENT_LAYERS = 20;@@ -74,7 +75,7 @@ export function updateRecentLayers(layer, allProjections) {if (existingEntry) {existingEntry.count += 1;- existingEntry.dateAdded = new Date().valueOf();+ existingEntry.dateAdded = util.now().valueOf();} else {if (layers.length === MAX_RECENT_LAYERS) {const [lowestCountLayer] = layers.sort((a, b) => a.count - b.count);@@ -89,7 +90,7 @@ export function updateRecentLayers(layer, allProjections) {recentLayers[proj].push({id: layerId,count: 1,- dateAdded: new Date().valueOf(),+ dateAdded: util.now().valueOf(),});}});diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 8088bfd0e..dc4ba3796 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -669,35 +669,28 @@ export default (function(self) {};/**- * Gets the current time. Use this instead of the Date methods to allow- * debugging alternate "now" times.+ * Gets the current time minus minutesOffset for geostationary layers.+ * Use this instead of the Date methods to allow debugging alternate "now" times.** @method now* @static* @return {Date} The current time or an overridden value.*/- const now = function() {- return new Date();+ const minutesOffset = 40 * 60000; // 40 minutes+ self.now = function() {+ return new Date(new Date().getTime() - minutesOffset);};- self.now = now;-/**- * Gets the current day. Use this instead of the Date methods to allow- * debugging alternate "now" dates.+ * Gets now minus one day, minus minutesOffset minutes for geostationary layers.*- * @method today+ * @method yesterday* @static* @return {Date} The current time with the UTC hours, minutes, and seconds- * fields set to zero or an overridden value.*/- self.today = function() {- return self.now();- };-self.yesterday = function() {- const now = new Date();- return new Date(now.setDate(now.getDate() - 1));+ const nowDate = self.now();+ return new Date(nowDate.setDate(nowDate.getDate() - 1));};/**