PKief / vscode-markdown-checkbox

Get it from the marketplace:
https://marketplace.visualstudio.com/items?itemName=PKief.markdown-checkbox
MIT License
34 stars 11 forks source link

"Date when checked" uses GMT for date? #10

Closed aefreedman closed 5 years ago

aefreedman commented 5 years ago

It looks like the date-when-checked doesn't adjust for timezone when determining the date. I get future dates when checking boxes in the evening.

PKief commented 5 years ago

Hi @aefreedman, the time is created by new Date() in JavaScript which is usually the current date of your system.

Here's the related line in the source code of this extension:

https://github.com/PKief/vscode-markdown-checkbox/blob/392cf5cf3e3d4aeac648ecc8e3e3abb370d66743/src/toggleCheckbox.ts#L68

Regarding the new Date() in JavaScript:

If no arguments are provided, the constructor creates a JavaScript Date object for the current date and time according to system settings for timezone offset. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Description)

Can you check if the timezone of your system is correct?

aefreedman commented 5 years ago

Hi @PKief, thanks for the response. Yes, my timezone is correct.

I think the date string should be const dateNow = new Date().toString().slice(0, 10);. toISOString() returns GMT+0 according to MDN.

PKief commented 5 years ago

Thank you, it should be fixed now!