1
0

Merge pull request #85 from hanzei/date-fix

Ensure dates consider timezones
This commit is contained in:
Zef Hemel 2022-10-08 15:48:38 +02:00 committed by GitHub
commit 78f83c70d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,11 @@
export function niceDate(d: Date): string {
return d.toISOString().split("T")[0];
function pad(n: number) {
let s = String(n);
if (s.length === 1) {
s = '0' + s;
}
return s;
}
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
}

View File

@ -143,8 +143,7 @@ export async function dailyNoteCommand() {
} catch {
console.warn(`No daily note template found at ${dailyNoteTemplate}`);
}
let isoDate = new Date().toISOString();
let date = isoDate.split("T")[0];
let date = niceDate(new Date())
let pageName = `${dailyNotePrefix}${date}`;
if (dailyNoteTemplateText) {
try {