From a05732869ffe0da60b8f49a906636bfb30c35c8f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:37:58 +0000 Subject: [PATCH 1/4] Initial plan From 2901efad6ef23b6648835048fe420621dc655960 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:47:40 +0000 Subject: [PATCH 2/4] Add date parsing for timestamps and date strings in pivot grid auto-config Co-authored-by: zdrawku <11193764+zdrawku@users.noreply.github.com> --- .../src/lib/grids/grid-base.directive.ts | 67 ++++++++- .../grids/pivot-grid/pivot-grid.component.ts | 42 ++++++ .../lib/grids/pivot-grid/pivot-grid.spec.ts | 142 ++++++++++++++++++ 3 files changed, 249 insertions(+), 2 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts index 8c7333526cf..1517567471a 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts @@ -7382,17 +7382,80 @@ export abstract class IgxGridBaseDirective implements GridType, */ public resolveDataTypes(rec) { if (typeof rec === 'number') { + // Check if number is a valid timestamp (milliseconds since epoch) + if (this.isValidTimestamp(rec)) { + return GridColumnDataType.Date; + } return GridColumnDataType.Number; } else if (typeof rec === 'boolean') { return GridColumnDataType.Boolean; } else if (typeof rec === 'object' && rec instanceof Date) { return GridColumnDataType.Date; - } else if (typeof rec === 'string' && (/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i).test(rec)) { - return GridColumnDataType.Image; + } else if (typeof rec === 'string') { + if ((/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i).test(rec)) { + return GridColumnDataType.Image; + } + // Check if string is a valid date string + if (this.isValidDateString(rec)) { + return GridColumnDataType.Date; + } } return GridColumnDataType.String; } + /** + * @hidden + * Checks if a number is a valid timestamp (milliseconds since epoch) + */ + private isValidTimestamp(value: number): boolean { + // Timestamps should be positive integers + if (!Number.isInteger(value) || value <= 0) { + return false; + } + // Reasonable timestamp range: from 1970 to year 2100 + // Min: 0 (Jan 1, 1970) + // Max: 4102444800000 (Jan 1, 2100) + const MIN_TIMESTAMP = 0; + const MAX_TIMESTAMP = 4102444800000; + if (value < MIN_TIMESTAMP || value > MAX_TIMESTAMP) { + return false; + } + // Check if it's in milliseconds range (10+ digits) to avoid false positives with regular numbers + // Timestamps after year 2001 have at least 10 digits + if (value < 1000000000000) { // Less than 10 digits in milliseconds + return false; + } + return true; + } + + /** + * @hidden + * Checks if a string represents a valid date + */ + private isValidDateString(value: string): boolean { + // Empty strings are not dates + if (!value || value.trim().length === 0) { + return false; + } + // Try to parse the string as a date + const parsedDate = new Date(value); + // Check if the date is valid (not NaN) and the string looks like a date + if (isNaN(parsedDate.getTime())) { + return false; + } + // Additional check: ensure the string contains date-like patterns + // to avoid false positives with strings like "2020" which could be just a year or a number string + const datePatterns = [ + /^\d{4}-\d{2}-\d{2}/, // ISO format: YYYY-MM-DD + /^\d{2}\/\d{2}\/\d{4}/, // US format: MM/DD/YYYY + /^\d{4}\/\d{2}\/\d{2}/, // Alternative: YYYY/MM/DD + /^\d{2}-\d{2}-\d{4}/, // Alternative: DD-MM-YYYY or MM-DD-YYYY + /^\d{1,2}\/\d{1,2}\/\d{2,4}/, // Flexible: M/D/YY or M/D/YYYY + /^\w{3}\s+\d{1,2},?\s+\d{4}/, // Text month: Jan 1, 2020 or Jan 1 2020 + ]; + return datePatterns.some(pattern => pattern.test(value.trim())); + } + /** * @hidden */ diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts index ee74558720d..cb816a7e932 100644 --- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts +++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts @@ -2401,7 +2401,9 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni const columnDimensions: IPivotDimension[] = []; const rowDimensions: IPivotDimension[] = []; const values: IPivotValue[] = []; + const dateFields: string[] = []; let isFirstDate = true; + fields.forEach((field) => { const dataType = this.resolveDataTypes(data[0][field]); switch (dataType) { @@ -2423,6 +2425,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni } case "date": { + dateFields.push(field); const dimension: IPivotDimension = new IgxPivotDateDimension( { memberName: field, @@ -2445,6 +2448,12 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni } } }); + + // Parse date-like values (timestamps and date strings) into Date objects + if (dateFields.length > 0) { + this.parseDateFields(data, dateFields); + } + const config: IPivotConfiguration = { columns: columnDimensions, rows: rowDimensions, @@ -2453,6 +2462,39 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni this.pivotConfiguration = config; } + /** + * @hidden + * Parses date-like values (timestamps and date strings) in the data into Date objects + */ + private parseDateFields(data: any[], dateFields: string[]): void { + if (!data || data.length === 0) { + return; + } + + for (const record of data) { + for (const field of dateFields) { + const value = record[field]; + // Skip if already a Date object or null/undefined + if (!value || value instanceof Date) { + continue; + } + + // Convert timestamp or date string to Date object + if (typeof value === 'number' || typeof value === 'string') { + try { + const parsedDate = new Date(value); + if (!isNaN(parsedDate.getTime())) { + record[field] = parsedDate; + } + } catch (e) { + // If parsing fails, leave the original value + console.warn(`Failed to parse date value for field '${field}':`, value); + } + } + } + } + } + protected createColumnForDimension(value: any, data: any, parent: ColumnType, isGroup: boolean) { const key = value.value; const ref = isGroup ? diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts index 223899f40d7..602ede79ecc 100644 --- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts @@ -2083,6 +2083,148 @@ describe('IgxPivotGrid #pivotGrid', () => { expect(pivotGrid.values.map(x => x.enabled)).toEqual([true, true]); }); + it('should auto-generate pivot config and parse date fields from timestamp values', () => { + const pivotGrid = fixture.componentInstance.pivotGrid; + pivotGrid.pivotConfiguration = undefined; + pivotGrid.autoGenerateConfig = true; + + // Test with timestamp (milliseconds since epoch) + const timestamp = 1577829600000; // 2020-01-01 00:00:00 UTC + pivotGrid.data = [{ + ProductCategory: 'Clothing', + UnitPrice: 12.81, + SellerName: 'Stanley', + Country: 'Bulgaria', + Date: timestamp, + UnitsSold: 282 + }]; + fixture.detectChanges(); + + // Verify date field is detected and config is generated + expect(pivotGrid.allDimensions.length).toEqual(4); + expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['AllPeriods']); + expect(pivotGrid.pivotConfiguration.rows.map(x => x.enabled)).toEqual([true]); + + // Verify the timestamp was converted to a Date object + expect(pivotGrid.data[0].Date instanceof Date).toBe(true); + expect(pivotGrid.data[0].Date.getTime()).toBe(timestamp); + + // values should be UnitPrice and UnitsSold (not Date) + expect(pivotGrid.values.length).toEqual(2); + expect(pivotGrid.values.map(x => x.member)).toEqual(['UnitPrice', 'UnitsSold']); + }); + + it('should auto-generate pivot config and parse date fields from ISO date strings', () => { + const pivotGrid = fixture.componentInstance.pivotGrid; + pivotGrid.pivotConfiguration = undefined; + pivotGrid.autoGenerateConfig = true; + + // Test with ISO date string + pivotGrid.data = [{ + ProductCategory: 'Clothing', + UnitPrice: 12.81, + SellerName: 'Stanley', + Country: 'Bulgaria', + Date: '2008-06-20', + UnitsSold: 282 + }]; + fixture.detectChanges(); + + // Verify date field is detected and config is generated + expect(pivotGrid.allDimensions.length).toEqual(4); + expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['AllPeriods']); + expect(pivotGrid.pivotConfiguration.rows.map(x => x.enabled)).toEqual([true]); + + // Verify the date string was converted to a Date object + expect(pivotGrid.data[0].Date instanceof Date).toBe(true); + expect(pivotGrid.data[0].Date.getFullYear()).toBe(2008); + expect(pivotGrid.data[0].Date.getMonth()).toBe(5); // June is month 5 (0-indexed) + expect(pivotGrid.data[0].Date.getDate()).toBe(20); + }); + + it('should auto-generate pivot config and parse date fields from US format date strings', () => { + const pivotGrid = fixture.componentInstance.pivotGrid; + pivotGrid.pivotConfiguration = undefined; + pivotGrid.autoGenerateConfig = true; + + // Test with US format date string (MM/DD/YYYY) + pivotGrid.data = [{ + ProductCategory: 'Clothing', + UnitPrice: 12.81, + SellerName: 'Stanley', + Country: 'Bulgaria', + Date: '10/24/2025', + UnitsSold: 282 + }]; + fixture.detectChanges(); + + // Verify date field is detected and config is generated + expect(pivotGrid.allDimensions.length).toEqual(4); + expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['AllPeriods']); + expect(pivotGrid.pivotConfiguration.rows.map(x => x.enabled)).toEqual([true]); + + // Verify the date string was converted to a Date object + expect(pivotGrid.data[0].Date instanceof Date).toBe(true); + expect(pivotGrid.data[0].Date.getFullYear()).toBe(2025); + expect(pivotGrid.data[0].Date.getMonth()).toBe(9); // October is month 9 (0-indexed) + expect(pivotGrid.data[0].Date.getDate()).toBe(24); + }); + + it('should handle multiple date fields and enable only the first one', () => { + const pivotGrid = fixture.componentInstance.pivotGrid; + pivotGrid.pivotConfiguration = undefined; + pivotGrid.autoGenerateConfig = true; + + // Test with multiple date fields + pivotGrid.data = [{ + ProductCategory: 'Clothing', + StartDate: 1577829600000, // timestamp + EndDate: '2020-12-31', // date string + UnitPrice: 12.81, + UnitsSold: 282 + }]; + fixture.detectChanges(); + + // Verify both date fields are detected + const rowDimensions = pivotGrid.pivotConfiguration.rows; + expect(rowDimensions.length).toEqual(2); + expect(rowDimensions.map(x => x.memberName)).toEqual(['AllPeriods', 'AllPeriods']); + + // Only the first date should be enabled by default + expect(rowDimensions[0].enabled).toBe(true); + expect(rowDimensions[1].enabled).toBe(false); + + // Verify both date values were parsed + expect(pivotGrid.data[0].StartDate instanceof Date).toBe(true); + expect(pivotGrid.data[0].EndDate instanceof Date).toBe(true); + }); + + it('should not treat regular numbers as timestamps', () => { + const pivotGrid = fixture.componentInstance.pivotGrid; + pivotGrid.pivotConfiguration = undefined; + pivotGrid.autoGenerateConfig = true; + + // Test with regular small numbers that should not be timestamps + pivotGrid.data = [{ + ProductCategory: 'Clothing', + Quantity: 100, // Regular number, not a timestamp + Year: 2020, // Year number, not a timestamp + UnitPrice: 12.81 + }]; + fixture.detectChanges(); + + // Verify no date fields were detected (all should be in values or columns) + expect(pivotGrid.pivotConfiguration.rows.length).toEqual(0); + + // Numbers should be treated as values + expect(pivotGrid.values.length).toEqual(3); + expect(pivotGrid.values.map(x => x.member).sort()).toEqual(['Quantity', 'Year', 'UnitPrice'].sort()); + + // Verify values were not converted + expect(pivotGrid.data[0].Quantity).toBe(100); + expect(pivotGrid.data[0].Year).toBe(2020); + }); + it('should allow creating IgxPivotDateDimension with no base dimension and setting it later.', () => { const pivotGrid = fixture.componentInstance.pivotGrid; const dateDimension = new IgxPivotDateDimension(); From 9c8ea6ee8d0ff36555d2e248e2dedeb4b5a8991d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Oct 2025 10:53:06 +0000 Subject: [PATCH 3/4] Address code review feedback: improve constants and comments Co-authored-by: zdrawku <11193764+zdrawku@users.noreply.github.com> --- .../src/lib/grids/grid-base.directive.ts | 7 ++++--- .../src/lib/grids/pivot-grid/pivot-grid.spec.ts | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts index 1517567471a..1d1b72fc414 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.directive.ts @@ -7420,9 +7420,10 @@ export abstract class IgxGridBaseDirective implements GridType, if (value < MIN_TIMESTAMP || value > MAX_TIMESTAMP) { return false; } - // Check if it's in milliseconds range (10+ digits) to avoid false positives with regular numbers - // Timestamps after year 2001 have at least 10 digits - if (value < 1000000000000) { // Less than 10 digits in milliseconds + // Check if it's in milliseconds range (13 digits) to avoid false positives with regular numbers + // Timestamps from year 2001 onwards have 13 digits: 1000000000000 = September 9, 2001 + const MIN_TIMESTAMP_MILLISECONDS = 1000000000000; + if (value < MIN_TIMESTAMP_MILLISECONDS) { return false; } return true; diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts index 602ede79ecc..371c8338a0c 100644 --- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts @@ -2089,13 +2089,13 @@ describe('IgxPivotGrid #pivotGrid', () => { pivotGrid.autoGenerateConfig = true; // Test with timestamp (milliseconds since epoch) - const timestamp = 1577829600000; // 2020-01-01 00:00:00 UTC + const TEST_TIMESTAMP = 1577829600000; // 2020-01-01 00:00:00 UTC pivotGrid.data = [{ ProductCategory: 'Clothing', UnitPrice: 12.81, SellerName: 'Stanley', Country: 'Bulgaria', - Date: timestamp, + Date: TEST_TIMESTAMP, UnitsSold: 282 }]; fixture.detectChanges(); @@ -2107,7 +2107,7 @@ describe('IgxPivotGrid #pivotGrid', () => { // Verify the timestamp was converted to a Date object expect(pivotGrid.data[0].Date instanceof Date).toBe(true); - expect(pivotGrid.data[0].Date.getTime()).toBe(timestamp); + expect(pivotGrid.data[0].Date.getTime()).toBe(TEST_TIMESTAMP); // values should be UnitPrice and UnitsSold (not Date) expect(pivotGrid.values.length).toEqual(2); @@ -2176,10 +2176,12 @@ describe('IgxPivotGrid #pivotGrid', () => { pivotGrid.autoGenerateConfig = true; // Test with multiple date fields + const TEST_START_TIMESTAMP = 1577829600000; // 2020-01-01 + const TEST_END_DATE_STRING = '2020-12-31'; pivotGrid.data = [{ ProductCategory: 'Clothing', - StartDate: 1577829600000, // timestamp - EndDate: '2020-12-31', // date string + StartDate: TEST_START_TIMESTAMP, // timestamp + EndDate: TEST_END_DATE_STRING, // date string UnitPrice: 12.81, UnitsSold: 282 }]; From d4b123a09c8d8a659996e18ca17970ba1998ebe8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Oct 2025 11:25:38 +0000 Subject: [PATCH 4/4] Optimize performance: Remove bulk date parsing, rely on on-demand conversion Co-authored-by: zdrawku <11193764+zdrawku@users.noreply.github.com> --- .../grids/pivot-grid/pivot-grid.component.ts | 40 ------------------ .../lib/grids/pivot-grid/pivot-grid.spec.ts | 41 +++++++++---------- 2 files changed, 20 insertions(+), 61 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts index cb816a7e932..cea85323bc4 100644 --- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts +++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts @@ -2401,7 +2401,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni const columnDimensions: IPivotDimension[] = []; const rowDimensions: IPivotDimension[] = []; const values: IPivotValue[] = []; - const dateFields: string[] = []; let isFirstDate = true; fields.forEach((field) => { @@ -2425,7 +2424,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni } case "date": { - dateFields.push(field); const dimension: IPivotDimension = new IgxPivotDateDimension( { memberName: field, @@ -2449,11 +2447,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni } }); - // Parse date-like values (timestamps and date strings) into Date objects - if (dateFields.length > 0) { - this.parseDateFields(data, dateFields); - } - const config: IPivotConfiguration = { columns: columnDimensions, rows: rowDimensions, @@ -2462,39 +2455,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni this.pivotConfiguration = config; } - /** - * @hidden - * Parses date-like values (timestamps and date strings) in the data into Date objects - */ - private parseDateFields(data: any[], dateFields: string[]): void { - if (!data || data.length === 0) { - return; - } - - for (const record of data) { - for (const field of dateFields) { - const value = record[field]; - // Skip if already a Date object or null/undefined - if (!value || value instanceof Date) { - continue; - } - - // Convert timestamp or date string to Date object - if (typeof value === 'number' || typeof value === 'string') { - try { - const parsedDate = new Date(value); - if (!isNaN(parsedDate.getTime())) { - record[field] = parsedDate; - } - } catch (e) { - // If parsing fails, leave the original value - console.warn(`Failed to parse date value for field '${field}':`, value); - } - } - } - } - } - protected createColumnForDimension(value: any, data: any, parent: ColumnType, isGroup: boolean) { const key = value.value; const ref = isGroup ? diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts index 371c8338a0c..6aadff4e007 100644 --- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts @@ -2083,7 +2083,7 @@ describe('IgxPivotGrid #pivotGrid', () => { expect(pivotGrid.values.map(x => x.enabled)).toEqual([true, true]); }); - it('should auto-generate pivot config and parse date fields from timestamp values', () => { + it('should auto-generate pivot config and detect date fields from timestamp values', () => { const pivotGrid = fixture.componentInstance.pivotGrid; pivotGrid.pivotConfiguration = undefined; pivotGrid.autoGenerateConfig = true; @@ -2105,27 +2105,28 @@ describe('IgxPivotGrid #pivotGrid', () => { expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['AllPeriods']); expect(pivotGrid.pivotConfiguration.rows.map(x => x.enabled)).toEqual([true]); - // Verify the timestamp was converted to a Date object - expect(pivotGrid.data[0].Date instanceof Date).toBe(true); - expect(pivotGrid.data[0].Date.getTime()).toBe(TEST_TIMESTAMP); + // Verify the timestamp is still in its original format (not pre-parsed) + // IgxPivotDateDimension will handle parsing on-demand + expect(pivotGrid.data[0].Date).toBe(TEST_TIMESTAMP); // values should be UnitPrice and UnitsSold (not Date) expect(pivotGrid.values.length).toEqual(2); expect(pivotGrid.values.map(x => x.member)).toEqual(['UnitPrice', 'UnitsSold']); }); - it('should auto-generate pivot config and parse date fields from ISO date strings', () => { + it('should auto-generate pivot config and detect date fields from ISO date strings', () => { const pivotGrid = fixture.componentInstance.pivotGrid; pivotGrid.pivotConfiguration = undefined; pivotGrid.autoGenerateConfig = true; // Test with ISO date string + const TEST_DATE_STRING = '2008-06-20'; pivotGrid.data = [{ ProductCategory: 'Clothing', UnitPrice: 12.81, SellerName: 'Stanley', Country: 'Bulgaria', - Date: '2008-06-20', + Date: TEST_DATE_STRING, UnitsSold: 282 }]; fixture.detectChanges(); @@ -2135,25 +2136,24 @@ describe('IgxPivotGrid #pivotGrid', () => { expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['AllPeriods']); expect(pivotGrid.pivotConfiguration.rows.map(x => x.enabled)).toEqual([true]); - // Verify the date string was converted to a Date object - expect(pivotGrid.data[0].Date instanceof Date).toBe(true); - expect(pivotGrid.data[0].Date.getFullYear()).toBe(2008); - expect(pivotGrid.data[0].Date.getMonth()).toBe(5); // June is month 5 (0-indexed) - expect(pivotGrid.data[0].Date.getDate()).toBe(20); + // Verify the date string is still in its original format (not pre-parsed) + // IgxPivotDateDimension will handle parsing on-demand + expect(pivotGrid.data[0].Date).toBe(TEST_DATE_STRING); }); - it('should auto-generate pivot config and parse date fields from US format date strings', () => { + it('should auto-generate pivot config and detect date fields from US format date strings', () => { const pivotGrid = fixture.componentInstance.pivotGrid; pivotGrid.pivotConfiguration = undefined; pivotGrid.autoGenerateConfig = true; // Test with US format date string (MM/DD/YYYY) + const TEST_US_DATE_STRING = '10/24/2025'; pivotGrid.data = [{ ProductCategory: 'Clothing', UnitPrice: 12.81, SellerName: 'Stanley', Country: 'Bulgaria', - Date: '10/24/2025', + Date: TEST_US_DATE_STRING, UnitsSold: 282 }]; fixture.detectChanges(); @@ -2163,11 +2163,9 @@ describe('IgxPivotGrid #pivotGrid', () => { expect(pivotGrid.pivotConfiguration.rows.map(x => x.memberName)).toEqual(['AllPeriods']); expect(pivotGrid.pivotConfiguration.rows.map(x => x.enabled)).toEqual([true]); - // Verify the date string was converted to a Date object - expect(pivotGrid.data[0].Date instanceof Date).toBe(true); - expect(pivotGrid.data[0].Date.getFullYear()).toBe(2025); - expect(pivotGrid.data[0].Date.getMonth()).toBe(9); // October is month 9 (0-indexed) - expect(pivotGrid.data[0].Date.getDate()).toBe(24); + // Verify the date string is still in its original format (not pre-parsed) + // IgxPivotDateDimension will handle parsing on-demand + expect(pivotGrid.data[0].Date).toBe(TEST_US_DATE_STRING); }); it('should handle multiple date fields and enable only the first one', () => { @@ -2196,9 +2194,10 @@ describe('IgxPivotGrid #pivotGrid', () => { expect(rowDimensions[0].enabled).toBe(true); expect(rowDimensions[1].enabled).toBe(false); - // Verify both date values were parsed - expect(pivotGrid.data[0].StartDate instanceof Date).toBe(true); - expect(pivotGrid.data[0].EndDate instanceof Date).toBe(true); + // Verify date values remain in their original format (not pre-parsed) + // IgxPivotDateDimension will handle parsing on-demand + expect(pivotGrid.data[0].StartDate).toBe(TEST_START_TIMESTAMP); + expect(pivotGrid.data[0].EndDate).toBe(TEST_END_DATE_STRING); }); it('should not treat regular numbers as timestamps', () => {