|
@@ -664,6 +664,15 @@ export const promptTemplate = (
|
|
hour12: true
|
|
hour12: true
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // Get the current weekday
|
|
|
|
+ const currentWeekday = getWeekday();
|
|
|
|
+
|
|
|
|
+ // Get the user's timezone
|
|
|
|
+ const currentTimezone = getUserTimezone();
|
|
|
|
+
|
|
|
|
+ // Get the user's language
|
|
|
|
+ const userLanguage = localStorage.getItem('locale') || 'en-US';
|
|
|
|
+
|
|
// Replace {{CURRENT_DATETIME}} in the template with the formatted datetime
|
|
// Replace {{CURRENT_DATETIME}} in the template with the formatted datetime
|
|
template = template.replace('{{CURRENT_DATETIME}}', `${formattedDate} ${currentTime}`);
|
|
template = template.replace('{{CURRENT_DATETIME}}', `${formattedDate} ${currentTime}`);
|
|
|
|
|
|
@@ -673,6 +682,15 @@ export const promptTemplate = (
|
|
// Replace {{CURRENT_TIME}} in the template with the formatted time
|
|
// Replace {{CURRENT_TIME}} in the template with the formatted time
|
|
template = template.replace('{{CURRENT_TIME}}', currentTime);
|
|
template = template.replace('{{CURRENT_TIME}}', currentTime);
|
|
|
|
|
|
|
|
+ // Replace {{CURRENT_WEEKDAY}} in the template with the current weekday
|
|
|
|
+ template = template.replace('{{CURRENT_WEEKDAY}}', currentWeekday);
|
|
|
|
+
|
|
|
|
+ // Replace {{CURRENT_TIMEZONE}} in the template with the user's timezone
|
|
|
|
+ template = template.replace('{{CURRENT_TIMEZONE}}', currentTimezone);
|
|
|
|
+
|
|
|
|
+ // Replace {{USER_LANGUAGE}} in the template with the user's language
|
|
|
|
+ template = template.replace('{{USER_LANGUAGE}}', userLanguage);
|
|
|
|
+
|
|
if (user_name) {
|
|
if (user_name) {
|
|
// Replace {{USER_NAME}} in the template with the user's name
|
|
// Replace {{USER_NAME}} in the template with the user's name
|
|
template = template.replace('{{USER_NAME}}', user_name);
|
|
template = template.replace('{{USER_NAME}}', user_name);
|
|
@@ -829,6 +847,34 @@ export const bestMatchingLanguage = (supportedLanguages, preferredLanguages, def
|
|
.map((prefLang) => languages.find((lang) => lang.startsWith(prefLang)))
|
|
.map((prefLang) => languages.find((lang) => lang.startsWith(prefLang)))
|
|
.find(Boolean);
|
|
.find(Boolean);
|
|
|
|
|
|
- console.log(languages, preferredLanguages, match, defaultLocale);
|
|
|
|
return match || defaultLocale;
|
|
return match || defaultLocale;
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+// Get the date in the format YYYY-MM-DD
|
|
|
|
+export const getFormattedDate = () => {
|
|
|
|
+ const date = new Date();
|
|
|
|
+ return date.toISOString().split('T')[0];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// Get the time in the format HH:MM:SS
|
|
|
|
+export const getFormattedTime = () => {
|
|
|
|
+ const date = new Date();
|
|
|
|
+ return date.toTimeString().split(' ')[0];
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// Get the current date and time in the format YYYY-MM-DD HH:MM:SS
|
|
|
|
+export const getCurrentDateTime = () => {
|
|
|
|
+ return `${getFormattedDate()} ${getFormattedTime()}`;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// Get the user's timezone
|
|
|
|
+export const getUserTimezone = () => {
|
|
|
|
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// Get the weekday
|
|
|
|
+export const getWeekday = () => {
|
|
|
|
+ const date = new Date();
|
|
|
|
+ const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
|
|
+ return weekdays[date.getDay()];
|
|
|
|
+};
|