Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions extensions/mssql/src/profiler/profilerConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,21 @@ export class ProfilerConfigService {
}

/**
* Format a timestamp for display.
* Converts timestamp to ISO 8601 format: "YYYY-MM-DD HH:mm:ss.sss"
* Format a timestamp for display in the local machine timezone.
* Format: "YYYY-MM-DD HH:mm:ss.SSS" (matching SSMS display)
* Example output: "2026-01-29 14:30:45.123"
Comment thread
allancascante marked this conversation as resolved.
*/
private formatTimestamp(timestamp: number): string {
try {
const date = new Date(timestamp);
return date.toISOString().replace("T", " ").replace("Z", "");
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
const ms = String(date.getMilliseconds()).padStart(3, "0");
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${ms}`;
} catch {
return String(timestamp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,14 @@ suite("ProfilerConfigService Tests", () => {
const event = createTestEvent({ timestamp: testTimestamp });
const viewRow = configService.convertEventToViewRow(event, view);

// Should be formatted as ISO string without T and Z
expect(viewRow.StartTime).to.include("2024-01-15");
expect(viewRow.StartTime).to.include("10:30:00");
// Should be formatted in local timezone as "YYYY-MM-DD HH:mm:ss.SSS"
const localYear = String(testTimestamp.getFullYear());
const localMonth = String(testTimestamp.getMonth() + 1).padStart(2, "0");
const localDay = String(testTimestamp.getDate()).padStart(2, "0");
const localHours = String(testTimestamp.getHours()).padStart(2, "0");
const localMinutes = String(testTimestamp.getMinutes()).padStart(2, "0");
expect(viewRow.StartTime).to.include(`${localYear}-${localMonth}-${localDay}`);
expect(viewRow.StartTime).to.include(`${localHours}:${localMinutes}:00`);
});
});

Expand Down Expand Up @@ -778,7 +783,7 @@ suite("ProfilerConfigService Tests", () => {
});
const typedRow = configService.convertEventToTypedRow(event, view);

// Timestamp is formatted as "2024-06-15 10:30:00.000" by getColumnValue,
// Timestamp is formatted in local timezone by getColumnValue,
// then coerced back to a Date by coerceToColumnType
expect(typedRow.StartTime).to.be.an.instanceOf(Date);
const startTime = typedRow.StartTime as Date;
Expand Down
Loading