mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-04 23:30:19 +01:00
📅 refactor: Replace Numeric Weekday Index with Named Day in Date Template Variables (#12022)
* feat(data-provider): include timezone and weekday label in current_datetime
* fix(data-provider): use named weekday for both date variables and single dayjs instance
Use a single `const now = dayjs()` instead of 5 separate instantiations,
apply named weekday to `{{current_date}}` (not just `{{current_datetime}}`),
simplify weekday format from `(weekday=Monday)` to `(Monday)`, and
harden test mock fallback to throw on unhandled format strings.
* chore(data-provider): remove dead day() mock from parsers spec
---------
Co-authored-by: Peter Rothlaender <peter.rothlaender@ginkgo.com>
This commit is contained in:
parent
a0a1749151
commit
2a5123bfa1
2 changed files with 22 additions and 21 deletions
|
|
@ -408,16 +408,16 @@ export function replaceSpecialVars({ text, user }: { text: string; user?: t.TUse
|
|||
return result;
|
||||
}
|
||||
|
||||
// e.g., "2024-04-29 (1)" (1=Monday)
|
||||
const currentDate = dayjs().format('YYYY-MM-DD');
|
||||
const dayNumber = dayjs().day();
|
||||
const combinedDate = `${currentDate} (${dayNumber})`;
|
||||
result = result.replace(/{{current_date}}/gi, combinedDate);
|
||||
const now = dayjs();
|
||||
const weekdayName = now.format('dddd');
|
||||
|
||||
const currentDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
result = result.replace(/{{current_datetime}}/gi, `${currentDatetime} (${dayNumber})`);
|
||||
const currentDate = now.format('YYYY-MM-DD');
|
||||
result = result.replace(/{{current_date}}/gi, `${currentDate} (${weekdayName})`);
|
||||
|
||||
const isoDatetime = dayjs().toISOString();
|
||||
const currentDatetime = now.format('YYYY-MM-DD HH:mm:ss Z');
|
||||
result = result.replace(/{{current_datetime}}/gi, `${currentDatetime} (${weekdayName})`);
|
||||
|
||||
const isoDatetime = now.toISOString();
|
||||
result = result.replace(/{{iso_datetime}}/gi, isoDatetime);
|
||||
|
||||
if (user && user.name) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue