Skip to content

Commit

Permalink
Fix bad date computation in auto-comment feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Apr 9, 2024
1 parent 846c646 commit a5f6c35
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a5f6c35

Please sign in to comment.