Skip to content

Commit

Permalink
Merge pull request #603 from odilitime/time-fix
Browse files Browse the repository at this point in the history
fix: time prompt to include UTC, convert to verbose english to help prompting
  • Loading branch information
shakkernerd authored Nov 26, 2024
2 parents 529f977 + d59c65e commit db9a857
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/plugin-bootstrap/src/providers/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import { IAgentRuntime, Memory, Provider, State } from "@ai16z/eliza";
const timeProvider: Provider = {
get: async (_runtime: IAgentRuntime, _message: Memory, _state?: State) => {
const currentDate = new Date();
const currentTime = currentDate.toLocaleTimeString("en-US");
const currentYear = currentDate.getFullYear();
return `The current time is: ${currentTime}, ${currentYear}`;

// Get UTC time since bots will be communicating with users around the global
const options = {
timeZone: "UTC",
dateStyle: "full" as "full",
timeStyle: "long" as "long",
};
const humanReadable = new Intl.DateTimeFormat("en-US", options).format(
currentDate
);
return `The current date and time is ${humanReadable}. Please use this as your reference for any time-based operations or responses.`;
},
};

export { timeProvider };

0 comments on commit db9a857

Please sign in to comment.