Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

common: add utility for formatting history session time

Abdullah Attae166a634f22c
diff --git a/packages/common/src/utils/time.ts b/packages/common/src/utils/time.ts
index 7a62b012f..05db187de 100644
--- a/packages/common/src/utils/time.ts
+++ b/packages/common/src/utils/time.ts
@@ -24,7 +24,7 @@ import {
} from "@notesnook/core/dist/utils/date";
import { database } from "../database";
import { formatReminderTime } from "@notesnook/core/dist/collections/reminders";
-import { Reminder } from "@notesnook/core/dist/types";
+import { HistorySession, Reminder } from "@notesnook/core/dist/types";
export function getFormattedDate(
date: string | number | Date,
@@ -43,3 +43,13 @@ export function getFormattedReminderTime(reminder: Reminder, short = false) {
timeFormat: database.settings?.getTimeFormat() as TimeFormat
});
}
+
+export function getFormattedHistorySessionDate(session: HistorySession) {
+ const fromDate = getFormattedDate(session.dateCreated, "date");
+ const toDate = getFormattedDate(session.dateModified, "date");
+ const fromTime = getFormattedDate(session.dateCreated, "time");
+ const toTime = getFormattedDate(session.dateModified, "time");
+ return `${fromDate}, ${fromTime} — ${
+ fromDate !== toDate ? `${toDate}, ` : ""
+ }${toTime}`;
+}