Skip to content

Commit 276c75e

Browse files
committed
Changed Time output to Zulu time + Local time including Timezone and adjusted tests.
1 parent e2bca75 commit 276c75e

File tree

2 files changed

+508
-546
lines changed

2 files changed

+508
-546
lines changed

src/core/Cline.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ export class Cline extends EventEmitter<ClineEvents> {
21032103
])
21042104
}
21052105

2106-
async getEnvironmentDetails(includeFileDetails: boolean = false) {
2106+
async getEnvironmentDetails(includeFileDetails: boolean = false, currentTime?: Date) {
21072107
let details = ""
21082108

21092109
const { terminalOutputLineLimit = 500, maxWorkspaceFiles = 200 } =
@@ -2256,19 +2256,13 @@ export class Cline extends EventEmitter<ClineEvents> {
22562256
}
22572257

22582258
// Add current time information with timezone
2259-
const now = new Date()
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}`
2259+
const now = currentTime ?? new Date()
2260+
// Get formatted time strings
2261+
const zuluTimeString = now.toISOString()
2262+
const localTimeString = now.toString()
2263+
2264+
details += `\n\n# Current Zulu Date/Time\n${zuluTimeString}`
2265+
details += `\n# Current Local Date/Time\n${localTimeString}`
22722266

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

0 commit comments

Comments
 (0)