Skip to content

Commit e2bca75

Browse files
committed
Switched Datetime format for <environment_details> to something clearer (ISO)
1 parent 82bf3dc commit e2bca75

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
@@ -2257,21 +2257,18 @@ export class Cline extends EventEmitter<ClineEvents> {
22572257

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

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

0 commit comments

Comments
 (0)