This repository was archived by the owner on May 20, 2026. It is now read-only.
feat: configurable time, weekday, and timezone in date context#5104
Open
eodus wants to merge 2 commits into
Open
feat: configurable time, weekday, and timezone in date context#5104eodus wants to merge 2 commits into
eodus wants to merge 2 commits into
Conversation
added 2 commits
May 3, 2026 23:57
Add three new settings under chat.advanced.context.*: - timeFormat: 'off' (default), '24h', or '12h' — controls time display - showWeekday: include day of week (default: false) - showTimezone: include timezone offset (default: false) All settings are opt-in; default behavior is unchanged (date only). Examples: - Default: 'The current date is May 3, 2026.' - All enabled (24h): 'The current date is Sunday, May 3, 2026. The current time is 23:06:32 GMT+2.' - All enabled (12h): 'The current date is Sunday, May 3, 2026. The current time is 11:06:32 PM GMT+2.' The date/time formatting logic is extracted into a shared formatCurrentDateContext() function used by the agent prompt path. All locales pinned to en-US for deterministic output. Unit tests included.
…ver) - India (GMT+5:30): verifies non-whole-hour offset formatting - Tokyo date rollover (UTC 23:30 → local next day): verifies weekday and date are correct when timezone shifts the calendar day
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds opt-in configuration to enrich the “current date” prompt context in agent mode by optionally including time, weekday, and timezone offset, via a shared formatter utility used by the agent prompt.
Changes:
- Added three new advanced settings (
timeFormat,showWeekday,showTimezone) and surfaced them inpackage.json+package.nls.json. - Introduced
formatCurrentDateContext()to produce deterministic, English (en-US) date/time strings and wired it into the agent prompt (CurrentDatePrompt). - Added a new Vitest suite covering combinations and multiple timezone scenarios.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/platform/configuration/common/configurationService.ts | Registers new advanced config keys for time/weekday/timezone context. |
| src/extension/prompts/node/agent/agentPrompt.tsx | Switches agent “current date” rendering to use the shared formatter + new config. |
| src/extension/prompts/common/currentDateContext.ts | Adds the shared date/time context formatter (en-US deterministic formatting, optional additions). |
| src/extension/prompts/common/test/currentDateContext.spec.ts | Adds unit tests for formatting across setting combinations and timezones. |
| package.nls.json | Adds localized setting descriptions for the new options. |
| package.json | Adds the new contributed settings schema (enum + booleans). |
Comment on lines
+23
to
+27
| beforeEach(() => { | ||
| vi.useFakeTimers(); | ||
| vi.stubEnv('TZ', 'UTC'); | ||
| // Monday, June 15, 2026 14:30:45 UTC | ||
| vi.setSystemTime(new Date('2026-06-15T14:30:45.000Z')); |
Member
|
Thanks for the contribution! This repository has been archived because the project has moved into the main VS Code repository. Could you please reopen/recreate this PR against: We’ll continue reviewing contributions there. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add three opt-in settings to include time, weekday, and timezone information in the date context provided to language models in agent mode.
Motivation
Time awareness is useful for models that assist with scheduling, deadlines, session duration tracking, and context-dependent responses. Currently only the date is provided. These settings allow users who want richer temporal context to opt in without affecting anyone else.
Settings
chat.advanced.context.timeFormat'off' | '24h' | '12h''off'chat.advanced.context.showWeekdaybooleanfalsechat.advanced.context.showTimezonebooleanfalseExamples
The current date is May 4, 2026.The current date is Monday, May 4, 2026. The current time is 17:09:32 GMT+2.The current date is Monday, May 4, 2026. The current time is 05:09:32 PM GMT+2.Implementation
formatCurrentDateContext()insrc/extension/prompts/common/currentDateContext.ts— used by the agent prompt path (CurrentDatePromptinagentPrompt.tsx).en-USfor deterministic output regardless of system locale. This also fixes a pre-existing issue where the date portion used the system locale, producing mixed-language output (e.g.,The current date is 3. Mai 2026.on German systems).Intl.DateTimeFormat.formatToParts()withtimeZoneName: 'shortOffset'for consistentGMT±Nformat across all regions.CurrentDatePromptinside<UserMessage>(viaAgentUserMessage), which changes every turn regardless — so even second-level precision has zero additional cache cost. The panel path (which renders the date inside<SystemMessage>) is intentionally untouched to avoid increasing its existing daily cache invalidation to per-second.Tests
16 unit tests with full determinism (
vi.useFakeTimers+vi.stubEnv('TZ', ...)+vi.setSystemTime):Backward compatibility
en-US(previously used system locale). This is intentional: the surrounding prompt text is English, so mixed-language dates were arguably a bug.