Skip to content

Commit a92ee56

Browse files
authored
Format time in ISO 8601 (RooCodeInc#5793)
1 parent a7a6bcb commit a92ee56

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/core/environment/getEnvironmentDetails.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,22 +179,12 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
179179
// Add current time information with timezone.
180180
const now = new Date()
181181

182-
const formatter = new Intl.DateTimeFormat(undefined, {
183-
year: "numeric",
184-
month: "numeric",
185-
day: "numeric",
186-
hour: "numeric",
187-
minute: "numeric",
188-
second: "numeric",
189-
hour12: true,
190-
})
191-
192-
const timeZone = formatter.resolvedOptions().timeZone
182+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
193183
const timeZoneOffset = -now.getTimezoneOffset() / 60 // Convert to hours and invert sign to match conventional notation
194184
const timeZoneOffsetHours = Math.floor(Math.abs(timeZoneOffset))
195185
const timeZoneOffsetMinutes = Math.abs(Math.round((Math.abs(timeZoneOffset) - timeZoneOffsetHours) * 60))
196186
const timeZoneOffsetStr = `${timeZoneOffset >= 0 ? "+" : "-"}${timeZoneOffsetHours}:${timeZoneOffsetMinutes.toString().padStart(2, "0")}`
197-
details += `\n\n# Current Time\n${formatter.format(now)} (${timeZone}, UTC${timeZoneOffsetStr})`
187+
details += `\n\n# Current Time\nCurrent time in ISO 8601 UTC format: ${now.toISOString()}\nUser time zone: ${timeZone}, UTC${timeZoneOffsetStr}`
198188

199189
// Add context tokens information.
200190
const { contextTokens, totalCost } = getApiMetrics(cline.clineMessages)

0 commit comments

Comments
 (0)