Skip to content

Scheduling infrastructure for absolutely everyone.

docs: add knowledge base against unnecessary Day.js usage (#23719)

Eunjae Lee3a7ca0246cc5
diff --git a/.agents/knowledge-base.md b/.agents/knowledge-base.md
index e9928353735..a2c57b14e38 100644
--- a/.agents/knowledge-base.md
+++ b/.agents/knowledge-base.md
@@ -318,3 +318,12 @@ dates.map((date) => dayjs.utc(date).add(1, "day").format());
// ✅ Best - Use native Date when possible
dates.map((date) => new Date(date.valueOf() + 24 * 60 * 60 * 1000));
```
+
+## Avoid using Dayjs if you don’t need to be strictly tz aware.
+
+When doing logic like Dayjs.startOf(".."), you can instead use date-fns' `startOfMonth(dateObj)` / `endOfDay(dateObj)`;
+When doing logic that depends on Browser locale, use i18n.language (prefer to deconstruct) like: `const { i18n: { language } } = useLocale();`, in combination with built-in Intl.
+
+Note that with Date, you’re dealing with System time, so it’s not suited to everywhere (such as in the Booker, where instead we’ll likely migrate to Temporal) - but in most cases the above are suitable.
+
+The main reason for doing so is that Dayjs uses a useful, but highly risky plugin system, which has led us to create `@calcom/dayjs` - this is heavy however, because it pre-loads ALL plugins, including locale handling. It’s a non-ideal solution to a problem that unfortunately exists due to Dayjs.