Skip to content

Show timezone abbreviation in system prompt#4901

Closed
dpalfox wants to merge 1 commit intoopenclaw:mainfrom
dpalfox:fix/timezone-abbreviation
Closed

Show timezone abbreviation in system prompt#4901
dpalfox wants to merge 1 commit intoopenclaw:mainfrom
dpalfox:fix/timezone-abbreviation

Conversation

@dpalfox
Copy link
Copy Markdown

@dpalfox dpalfox commented Jan 30, 2026

Adds \getTimezoneAbbreviation()\ to convert IANA timezone names (e.g. \America/New_York) to friendly abbreviations (e.g. \EST).

The system prompt now shows:
\
Time zone: America/New_York (EST)
\
instead of just:
\
Time zone: America/New_York
\\

This makes it easier for the AI to understand and communicate about timezones.

Greptile Overview

Greptile Summary

This PR adds getTimezoneAbbreviation() in src/agents/date-time.ts and updates buildTimeSection() in src/agents/system-prompt.ts to display the user’s IANA timezone along with a short Intl.DateTimeFormat-derived timezone label (e.g., America/New_York (EST)) when they differ.

The change integrates into the system prompt construction path by enriching the existing “Current Date & Time” section, without altering other prompt sections or the timezone resolution logic.

Confidence Score: 4/5

  • This PR is likely safe to merge, with minor correctness/UX concerns around what Intl returns for “short” timezone names.
  • Changes are small and localized, and use a standard Intl.DateTimeFormat API with a try/catch fallback. The main risk is that timeZoneName: "short" does not reliably produce abbreviations like EST/PST across environments/locales and can yield GMT offsets (e.g., GMT-5) or localized strings, which may reduce the intended benefit but shouldn’t break functionality.
  • src/agents/date-time.ts (abbreviation semantics), src/agents/system-prompt.ts (display logic expectations)

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

Adds getTimezoneAbbreviation() to convert IANA timezone names (e.g. America/New_York) to friendly abbreviations (e.g. EST).

The system prompt now shows: Time zone: America/New_York (EST)
instead of just: Time zone: America/New_York
@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Jan 30, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +26 to +38
export function getTimezoneAbbreviation(timezone: string): string {
try {
const formatter = new Intl.DateTimeFormat("en-US", {
timeZone: timezone,
timeZoneName: "short",
});
const parts = formatter.formatToParts(new Date());
const tzPart = parts.find((p) => p.type === "timeZoneName");
return tzPart?.value ?? timezone;
} catch {
return timezone;
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] timeZoneName: "short" may not yield true abbreviations across environments

Intl.DateTimeFormat(..., { timeZoneName: "short" }) often returns offsets like GMT-5/UTC−05:00 or localized strings (and can vary by Node/ICU build), so getTimezoneAbbreviation() may not reliably produce EST/PST as the PR description implies. If the goal is a stable, friendly label, consider renaming the function (e.g. to getTimezoneShortName) or using timeZoneName: "shortGeneric"/"shortOffset" depending on the desired output semantics.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/date-time.ts
Line: 26:38

Comment:
[P2] `timeZoneName: "short"` may not yield true abbreviations across environments

`Intl.DateTimeFormat(..., { timeZoneName: "short" })` often returns offsets like `GMT-5`/`UTC−05:00` or localized strings (and can vary by Node/ICU build), so `getTimezoneAbbreviation()` may not reliably produce `EST/PST` as the PR description implies. If the goal is a stable, friendly label, consider renaming the function (e.g. to `getTimezoneShortName`) or using `timeZoneName: "shortGeneric"`/`"shortOffset"` depending on the desired output semantics.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 52 to 59
function buildTimeSection(params: { userTimezone?: string }) {
if (!params.userTimezone) return [];
return ["## Current Date & Time", `Time zone: ${params.userTimezone}`, ""];
const abbrev = getTimezoneAbbreviation(params.userTimezone);
// Show both IANA name and abbreviation if they differ
const tzDisplay =
abbrev !== params.userTimezone ? `${params.userTimezone} (${abbrev})` : params.userTimezone;
return ["## Current Date & Time", `Time zone: ${tzDisplay}`, ""];
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Consider trimming before comparing to avoid duplicate display from whitespace/casing

buildTimeSection() compares abbrev !== params.userTimezone, but params.userTimezone can include whitespace (it’s trimmed later in buildAgentSystemPrompt). If buildTimeSection is ever reused elsewhere, you could end up with America/New_York (America/New_York)-style output due purely to whitespace. Passing the already-trimmed userTimezone down (or trimming locally before both the call and the comparison) keeps the display stable.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/system-prompt.ts
Line: 52:59

Comment:
[P3] Consider trimming before comparing to avoid duplicate display from whitespace/casing

`buildTimeSection()` compares `abbrev !== params.userTimezone`, but `params.userTimezone` can include whitespace (it’s trimmed later in `buildAgentSystemPrompt`). If `buildTimeSection` is ever reused elsewhere, you could end up with `America/New_York (America/New_York)`-style output due purely to whitespace. Passing the already-trimmed `userTimezone` down (or trimming locally before both the call and the comparison) keeps the display stable.

How can I resolve this? If you propose a fix, please make it concise.

@mudrii

This comment was marked as spam.

@mudrii

This comment was marked as spam.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 7, 2026
@dpalfox
Copy link
Copy Markdown
Author

dpalfox commented Mar 7, 2026

Still relevant — this is a small quality-of-life improvement that helps the AI reason about timezones more naturally. Happy to rebase if needed.

@openclaw-barnacle openclaw-barnacle bot removed the stale Marked as stale due to inactivity label Mar 8, 2026
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 14, 2026
@openclaw-barnacle
Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants