From 358e1e99c5c28bb1d45626cc332d67885da8965b Mon Sep 17 00:00:00 2001 From: Cats Juice Date: Tue, 5 Mar 2024 03:37:23 +0000 Subject: [PATCH] feat(core): set journal's really created time (#5968) closes #5958; This makes the creation date of the journal correspond to the date, and the creation time is the real creation time. --- packages/frontend/core/src/hooks/use-journal.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/frontend/core/src/hooks/use-journal.ts b/packages/frontend/core/src/hooks/use-journal.ts index c169a6a96e..695456eac0 100644 --- a/packages/frontend/core/src/hooks/use-journal.ts +++ b/packages/frontend/core/src/hooks/use-journal.ts @@ -31,11 +31,17 @@ export const useJournalHelper = (workspace: BlockSuiteWorkspace) => { */ const _createJournal = useCallback( (maybeDate: MaybeDate) => { - const title = dayjs(maybeDate).format(JOURNAL_DATE_FORMAT); + const day = dayjs(maybeDate); + const title = day.format(JOURNAL_DATE_FORMAT); const page = bsWorkspaceHelper.createDoc(); // set created date to match the journal date page.workspace.setDocMeta(page.id, { - createDate: dayjs(maybeDate).toDate().getTime(), + createDate: dayjs() + .set('year', day.year()) + .set('month', day.month()) + .set('date', day.date()) + .toDate() + .getTime(), }); initEmptyPage(page, title); adapter.setJournalPageDateString(page.id, title);