proof of concept for time travel

This commit is contained in:
Phillip Thelen
2024-02-13 09:41:39 +01:00
committed by Sabe Jones
parent 127f105934
commit 1b12e9d8b7
5 changed files with 38 additions and 26 deletions

13
package-lock.json generated
View File

@@ -9705,19 +9705,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
}, },
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",

View File

@@ -6982,19 +6982,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
}, },
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",

View File

@@ -300,6 +300,9 @@
> >
Toggle Debug Menu Toggle Debug Menu
</button> </button>
<div>
Today is {{ new Date() }}
</div>
<div <div
v-if="debugMenuShown" v-if="debugMenuShown"
class="debug-toggle debug-group" class="debug-toggle debug-group"

View File

@@ -1,4 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import sinon from 'sinon';
import BootstrapVue from 'bootstrap-vue'; import BootstrapVue from 'bootstrap-vue';
import Fragment from 'vue-fragment'; import Fragment from 'vue-fragment';
import AppComponent from './app'; import AppComponent from './app';
@@ -13,6 +14,7 @@ import './filters/registerGlobals';
import i18n from './libs/i18n'; import i18n from './libs/i18n';
import 'smartbanner.js/dist/smartbanner'; import 'smartbanner.js/dist/smartbanner';
let jumped = false;
const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env
// Configure Vue global options, see https://vuejs.org/v2/api/#Global-Config // Configure Vue global options, see https://vuejs.org/v2/api/#Global-Config
@@ -35,6 +37,21 @@ setUpLogging();
setupAnalytics(); // just create queues for analytics, no scripts loaded at this time setupAnalytics(); // just create queues for analytics, no scripts loaded at this time
const store = getStore(); const store = getStore();
const time = new Date(2024, 2, 18);
const clock = sinon.useFakeTimers({
now: time,
shouldAdvanceTime: true,
});
setInterval(() => {
if (jumped) {
jumped = false;
return;
}
jumped = true;
clock.jump(36000);
}, 1000);
const vueInstance = new Vue({ const vueInstance = new Vue({
el: '#app', el: '#app',
router, router,

View File

@@ -2,6 +2,7 @@ import nconf from 'nconf';
import express from 'express'; import express from 'express';
import http from 'http'; import http from 'http';
import logger from './libs/logger'; import logger from './libs/logger';
import sinon from 'sinon';
// Setup translations // Setup translations
// Must come before attach middlewares so Mongoose validations can use translations // Must come before attach middlewares so Mongoose validations can use translations
@@ -25,6 +26,23 @@ app.set('port', nconf.get('PORT'));
attachMiddlewares(app, server); attachMiddlewares(app, server);
const time = new Date(2024, 2, 18);
const clock = sinon.useFakeTimers({
now: time,
shouldAdvanceTime: true,
});
var jumped = false;
setInterval(() => {
if (jumped) {
jumped = false;
return;
}
jumped = true;
console.log('Jumping time');
clock.jump(36000);
}, 1000);
server.on('request', app); server.on('request', app);
server.listen(app.get('port'), () => { server.listen(app.get('port'), () => {
logger.info(`Express server listening on port ${app.get('port')}`); logger.info(`Express server listening on port ${app.get('port')}`);