Skip to content

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

refactor: extendable formatDate function

thecodrr5337dd482c45
diff --git a/packages/core/utils/date.js b/packages/core/utils/date.js
index 3202af491..bef7cb290 100644
--- a/packages/core/utils/date.js
+++ b/packages/core/utils/date.js
@@ -11,9 +11,18 @@ export function getWeekGroupFromTimestamp(timestamp) {
)}`;
}
-export function formatDate(date) {
- return new Date(date).toLocaleString(undefined, {
+/**
+ *
+ * @param {number} date
+ * @param {Intl.DateTimeFormatOptions} options
+ * @returns
+ */
+export function formatDate(
+ date,
+ options = {
dateStyle: "medium",
timeStyle: "short",
- });
+ }
+) {
+ return new Date(date).toLocaleString(undefined, options);
}