diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js index 7429e71c06..49e0c92ff0 100644 --- a/frontend_tests/node_tests/drafts.js +++ b/frontend_tests/node_tests/drafts.js @@ -54,7 +54,7 @@ function stub_timestamp(timestamp, func) { function fake_time() { return timestamp; } - with_field(Date.prototype, "getTime", fake_time, func); + with_field(Date, "now", fake_time, func); } const legacy_draft = { diff --git a/static/js/debug.js b/static/js/debug.js index 086a94af9a..94b7b8bcc1 100644 --- a/static/js/debug.js +++ b/static/js/debug.js @@ -11,9 +11,9 @@ to the console along with the name "foo". */ export function print_elapsed_time(name, fun) { - const t0 = new Date().getTime(); + const t0 = Date.now(); const out = fun(); - const t1 = new Date().getTime(); + const t1 = Date.now(); console.log(name + ": " + (t1 - t0) + " ms"); return out; } diff --git a/static/js/drafts.js b/static/js/drafts.js index 1cffbabbd7..9b1ac59721 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -23,7 +23,7 @@ const draft_model = (function () { ls.version = 1; function getTimestamp() { - return new Date().getTime(); + return Date.now(); } function get() { diff --git a/static/js/feedback_widget.js b/static/js/feedback_widget.js index 7527138013..7601939d22 100644 --- a/static/js/feedback_widget.js +++ b/static/js/feedback_widget.js @@ -33,7 +33,7 @@ const animate = { return; } - if (meta.hide_me_time < new Date().getTime() && !meta.alert_hover_state) { + if (meta.hide_me_time < Date.now() && !meta.alert_hover_state) { animate.fadeOut(); return; } @@ -89,7 +89,7 @@ function set_up_handlers() { meta.alert_hover_state = false; // add at least 2000ms but if more than that exists just keep the // current amount. - meta.hide_me_time = Math.max(meta.hide_me_time, new Date().getTime() + 2000); + meta.hide_me_time = Math.max(meta.hide_me_time, Date.now() + 2000); }); meta.$container.on("click", ".exit-me", () => { @@ -128,7 +128,7 @@ exports.show = function (opts) { meta.undo = opts.on_undo; // add a four second delay before closing up. - meta.hide_me_time = new Date().getTime() + 4000; + meta.hide_me_time = Date.now() + 4000; meta.$container.find(".feedback_title").text(opts.title_text); meta.$container.find(".feedback_undo").text(opts.undo_button_text); diff --git a/static/js/localstorage.js b/static/js/localstorage.js index 188d5b5350..c2462b74a4 100644 --- a/static/js/localstorage.js +++ b/static/js/localstorage.js @@ -26,7 +26,7 @@ const ls = { return { data, __valid: true, - expires: new Date().getTime() + expires, + expires: Date.now() + expires, }; }, diff --git a/static/js/message_edit.js b/static/js/message_edit.js index 23fd915e8c..494a6b9977 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -758,7 +758,7 @@ exports.save_message_row_edit = function (row) { // Settings these attributes causes a "SAVING" notice to // briefly appear where "EDITED" would normally appear until // the message is acknowledged by the server. - message.local_edit_timestamp = Math.round(new Date().getTime() / 1000); + message.local_edit_timestamp = Math.round(Date.now() / 1000); echo.edit_locally(message, currently_echoing_messages.get(message_id)); diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index d79362f3a0..52f2b2c615 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -4,7 +4,7 @@ const render_muted_topic_ui_row = require("../templates/muted_topic_ui_row.hbs") const render_topic_muted = require("../templates/topic_muted.hbs"); function timestamp_ms() { - return new Date().getTime(); + return Date.now(); } let last_topic_update = 0; diff --git a/static/js/popovers.js b/static/js/popovers.js index 874c048f73..07b5b1a700 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -1260,7 +1260,7 @@ exports.register_click_handlers = function () { return; } - const date = new Date().getTime(); + const date = Date.now(); // only run `popovers.hide_all()` if the last scroll was more // than 250ms ago. diff --git a/static/js/setup.js b/static/js/setup.js index fdc9884daf..218b28c6bc 100644 --- a/static/js/setup.js +++ b/static/js/setup.js @@ -15,7 +15,7 @@ $(() => { page_params.needs_tutorial = false; } - page_params.page_load_time = new Date().getTime(); + page_params.page_load_time = Date.now(); // Display loading indicator. This disappears after the first // get_events completes. diff --git a/static/js/typing.js b/static/js/typing.js index d7e7bc35d9..830442dc8b 100644 --- a/static/js/typing.js +++ b/static/js/typing.js @@ -43,7 +43,7 @@ function is_valid_conversation() { } function get_current_time() { - return new Date().getTime(); + return Date.now(); } function notify_server_start(user_ids_array) {