From a5f6c35bb091d26693fd1f7986e499905b7b8e73 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 9 Apr 2024 12:15:03 -0400 Subject: [PATCH] Fix bad date computation in auto-comment feature Related feedback: https://old.reddit.com/r/uBlockOrigin/comments/1bxz6oi/ --- src/js/storage.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/js/storage.js b/src/js/storage.js index cd340fca9..9ccd9e062 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -605,14 +605,10 @@ onBroadcast(msg => { this.hiddenSettings.autoCommentFilterTemplate.indexOf('{{') !== -1 ) { const d = new Date(); - // Date in YYYY-MM-DD format - https://stackoverflow.com/a/50130338 - const ISO8601Date = new Date(d.getTime() + - (d.getTimezoneOffset()*60000)).toISOString().split('T')[0]; const url = new URL(options.docURL); - comment = - '! ' + + comment = '! ' + this.hiddenSettings.autoCommentFilterTemplate - .replace('{{date}}', ISO8601Date) + .replace('{{date}}', d.toLocaleDateString(undefined, { dateStyle: 'medium' })) .replace('{{time}}', d.toLocaleTimeString()) .replace('{{hostname}}', url.hostname) .replace('{{origin}}', url.origin)