Skip to content

Commit d0c725a

Browse files
committed
Switched Datetime format for <environment_details> to something clearer (ISO)
1 parent 57d9731 commit d0c725a

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/core/Cline.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,21 +2259,18 @@ export class Cline extends EventEmitter<ClineEvents> {
22592259

22602260
// Add current time information with timezone
22612261
const now = new Date()
2262-
const formatter = new Intl.DateTimeFormat(undefined, {
2263-
year: "numeric",
2264-
month: "numeric",
2265-
day: "numeric",
2266-
hour: "numeric",
2267-
minute: "numeric",
2268-
second: "numeric",
2269-
hour12: true,
2270-
})
2271-
const timeZone = formatter.resolvedOptions().timeZone
2272-
const timeZoneOffset = -now.getTimezoneOffset() / 60 // Convert to hours and invert sign to match conventional notation
2273-
const timeZoneOffsetHours = Math.floor(Math.abs(timeZoneOffset))
2274-
const timeZoneOffsetMinutes = Math.abs(Math.round((Math.abs(timeZoneOffset) - timeZoneOffsetHours) * 60))
2275-
const timeZoneOffsetStr = `${timeZoneOffset >= 0 ? "+" : "-"}${timeZoneOffsetHours}:${timeZoneOffsetMinutes.toString().padStart(2, "0")}`
2276-
details += `\n\n# Current Time\n${formatter.format(now)} (${timeZone}, UTC${timeZoneOffsetStr})`
2262+
// Calculate timezone offset
2263+
const tzOffset = -now.getTimezoneOffset() // in minutes
2264+
const sign = tzOffset >= 0 ? "+" : "-"
2265+
const pad = (num: number) => String(Math.floor(Math.abs(num))).padStart(2, "0")
2266+
const offsetHours = pad(tzOffset / 60)
2267+
const offsetMinutes = pad(tzOffset % 60)
2268+
2269+
// Remove the trailing 'Z' from ISO string and add the custom offset
2270+
const isoWithoutZ = now.toISOString().replace("Z", "")
2271+
const isoString = `${isoWithoutZ}${sign}${offsetHours}:${offsetMinutes}`
2272+
2273+
details += `\n\n# Current Time\n${isoString}`
22772274

22782275
// Add context tokens information
22792276
const { contextTokens, totalCost } = getApiMetrics(this.clineMessages)

0 commit comments

Comments
 (0)