Prefer Date.now() when possible

This commit is contained in:
Maximilian Krög
2021-07-02 23:01:11 +02:00
parent f506f4bdc9
commit d7d0eeb7c7
4 changed files with 4 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ function addRandomFeature() {
const duration = 3000; const duration = 3000;
function flash(feature) { function flash(feature) {
const start = new Date().getTime(); const start = Date.now();
const flashGeom = feature.getGeometry().clone(); const flashGeom = feature.getGeometry().clone();
const listenerKey = tileLayer.on('postrender', animate); const listenerKey = tileLayer.on('postrender', animate);

View File

@@ -142,7 +142,7 @@ fetch('data/polyline/route.json').then(function (response) {
stopAnimation(false); stopAnimation(false);
} else { } else {
animating = true; animating = true;
startTime = new Date().getTime(); startTime = Date.now();
speed = speedInput.value; speed = speedInput.value;
startButton.textContent = 'Cancel Animation'; startButton.textContent = 'Cancel Animation';
// hide geoMarker // hide geoMarker

View File

@@ -120,7 +120,7 @@ function animateFlights(event) {
function addLater(feature, timeout) { function addLater(feature, timeout) {
window.setTimeout(function () { window.setTimeout(function () {
feature.set('start', new Date().getTime()); feature.set('start', Date.now());
flightsSource.addFeature(feature); flightsSource.addFeature(feature);
}, timeout); }, timeout);
} }

View File

@@ -46,7 +46,7 @@ function updateInfo() {
function setTime() { function setTime() {
startDate.setMinutes(startDate.getMinutes() + 15); startDate.setMinutes(startDate.getMinutes() + 15);
if (startDate > new Date()) { if (startDate > Date.now()) {
startDate = threeHoursAgo(); startDate = threeHoursAgo();
} }
layers[1].getSource().updateParams({'TIME': startDate.toISOString()}); layers[1].getSource().updateParams({'TIME': startDate.toISOString()});