diff --git a/js/common_functions.js b/js/common_functions.js index a2a2e1d..6075d19 100644 --- a/js/common_functions.js +++ b/js/common_functions.js @@ -2005,35 +2005,31 @@ function html_escape(html) /*"*/ function he(html){return html_escape(html);} -function future_ms(ms) -{ - var c=new Date(); - c.setUTCMilliseconds(c.getUTCMilliseconds()+ms); - return c; +function future_ms(ms) { + return new Date(Date.now() + ms); } -function future_s(s) -{ - var c=new Date(); - c.setUTCSeconds(c.getUTCSeconds()+s); - return c; +function future_s(s) { + return future_ms(s * 1000); } -function future_m(m) -{ - return future_s(60*m); +function future_m(m) { + return future_ms(m * 60000); } -function future_h(h) -{ - return future_m(60*h); +function future_h(h) { + return future_ms(h * 3600000); } -function mssince(t,ref) -{ - if(!ref) ref=new Date(); - return ref.getTime() - t.getTime(); +function mssince(t, ref = Date.now()) { + return ref instanceof Date ? ref.getTime() - t.getTime() : ref - t.getTime(); +} +function ssince(t, ref) { + return mssince(t, ref) / 1000; +} +function msince(t, ref) { + return mssince(t, ref) / 60000; +} +function hsince(t, ref) { + return mssince(t, ref) / 3600000; } -function ssince(t,ref) { return mssince(t,ref)/1000.0; } -function msince(t,ref) { return mssince(t,ref)/60000.0; } -function hsince(t,ref) { return mssince(t,ref)/3600000.0; } function sleep(ms) { diff --git a/node/.eslintrc b/node/.eslintrc index a806da0..a37aed9 100644 --- a/node/.eslintrc +++ b/node/.eslintrc @@ -1,25 +1,25 @@ { - "extends": ["eslint:recommended", "eslint-config-prettier"], - "env": { - "node": true - }, - "parserOptions": { - "ecmaVersion": 10 - }, - "plugins": ["prettier"], - "rules": { - "no-constant-condition": "off", - "no-dupe-else-if": "off", - "indent": "off", - "no-empty": "warn", - "no-inner-declarations": "warn", - "no-unreachable": "warn", - "no-undef": "warn", - "no-unused-vars": "warn", - "no-redeclare": "warn", - "curly": "error", - "prettier/prettier": "error", - "one-var": ["error", "never"], - "no-sequences": "error" - } + "extends": ["eslint:recommended", "eslint-config-prettier"], + "env": { + "node": true + }, + "parserOptions": { + "ecmaVersion": 2021 + }, + "plugins": ["prettier"], + "rules": { + "no-constant-condition": "off", + "no-dupe-else-if": "off", + "indent": "off", + "no-empty": "warn", + "no-inner-declarations": "warn", + "no-unreachable": "warn", + "no-undef": "warn", + "no-unused-vars": "warn", + "no-redeclare": "warn", + "curly": "error", + "prettier/prettier": "error", + "one-var": ["error", "never"], + "no-sequences": "error" + } }