1
0
silverbullet/packages/plugs/core/dates.ts

18 lines
442 B
TypeScript
Raw Normal View History

import { insertAtCursor } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
2022-04-10 09:04:07 +00:00
const dateMatchRegex = /(\d{4}\-\d{2}\-\d{2})/g;
2022-04-11 18:34:09 +00:00
export function niceDate(d: Date): string {
return d.toISOString().split("T")[0];
2022-04-11 18:34:09 +00:00
}
2022-02-24 16:24:49 +00:00
export async function insertToday() {
2022-04-11 18:34:09 +00:00
await insertAtCursor(niceDate(new Date()));
2022-04-10 09:04:07 +00:00
}
export async function insertTomorrow() {
let d = new Date();
d.setDate(d.getDate() + 1);
2022-04-11 18:34:09 +00:00
await insertAtCursor(niceDate(d));
2022-02-24 16:24:49 +00:00
}