From 6c00403a874dd3132de6995d4dcd9e4ebf9dfb82 Mon Sep 17 00:00:00 2001 From: cusher <30704914+cusher@users.noreply.github.com> Date: Wed, 5 Apr 2023 20:01:10 -1000 Subject: [PATCH 1/3] fix(material-luxon-adapter): zone on DateTime ignored (#26887) Fixes a bug where the timezone on the Luxon DateTime is thrown away during conversion to string, resulting in using the Luxon defaultZone regardless of how the particular DateTime is configured. Fixes #26869 (cherry picked from commit 00ff979b966e52565df0755570205548f2cc8467) --- .../adapter/luxon-date-adapter.spec.ts | 12 +++++++++++- .../adapter/luxon-date-adapter.ts | 9 +++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts b/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts index 306b5c7aed59..8ee5312d04cf 100644 --- a/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts +++ b/src/material-luxon-adapter/adapter/luxon-date-adapter.spec.ts @@ -9,7 +9,7 @@ import {LOCALE_ID} from '@angular/core'; import {TestBed, waitForAsync} from '@angular/core/testing'; import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core'; -import {DateTime} from 'luxon'; +import {DateTime, FixedOffsetZone, Settings} from 'luxon'; import {LuxonDateModule} from './index'; import {MAT_LUXON_DATE_ADAPTER_OPTIONS} from './luxon-date-adapter'; @@ -351,6 +351,16 @@ describe('LuxonDateAdapter', () => { expect(date).toEqual('2. jan. 2017'); }); + it('should format with a different timezone', () => { + Settings.defaultZone = FixedOffsetZone.parseSpecifier('UTC-12'); + + let date = adapter.format(DateTime.local(2017, JAN, 2, {zone: 'UTC-12'}), 'DD'); + expect(date).toEqual('Jan 2, 2017'); + + date = adapter.format(DateTime.local(2017, JAN, 2, {zone: 'UTC+12'}), 'DD'); + expect(date).toEqual('Jan 2, 2017'); + }); + it('should throw when attempting to format invalid date', () => { expect(() => adapter.format(DateTime.fromMillis(NaN), 'LL/dd/yyyy')).toThrowError( /LuxonDateAdapter: Cannot format invalid date\./, diff --git a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts index f1a67d916394..663859c3aac1 100644 --- a/src/material-luxon-adapter/adapter/luxon-date-adapter.ts +++ b/src/material-luxon-adapter/adapter/luxon-date-adapter.ts @@ -193,10 +193,11 @@ export class LuxonDateAdapter extends DateAdapter { if (!this.isValid(date)) { throw Error('LuxonDateAdapter: Cannot format invalid date.'); } - return date - .setLocale(this.locale) - .setZone(this._useUTC ? 'utc' : undefined) - .toFormat(displayFormat); + if (this._useUTC) { + return date.setLocale(this.locale).setZone('utc').toFormat(displayFormat); + } else { + return date.setLocale(this.locale).toFormat(displayFormat); + } } addCalendarYears(date: LuxonDateTime, years: number): LuxonDateTime { From de22cdc7227187ad11e385caf0456639cfea1da8 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Wed, 12 Apr 2023 06:07:54 -0600 Subject: [PATCH 2/3] fix(material/table): correct filterPredicate typo (#26902) (cherry picked from commit fedc9d42c44c9ca10c27541af12f734a1e34141d) --- src/material/legacy-table/table-data-source.ts | 2 +- src/material/table/table-data-source.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/material/legacy-table/table-data-source.ts b/src/material/legacy-table/table-data-source.ts index f8a2e2cde882..c92f4b360031 100644 --- a/src/material/legacy-table/table-data-source.ts +++ b/src/material/legacy-table/table-data-source.ts @@ -14,7 +14,7 @@ import {_MatTableDataSource} from '@angular/material/table'; * sorting (using MatSort), and pagination (using paginator). * * Allows for sort customization by overriding sortingDataAccessor, which defines how data - * properties are accessed. Also allows for filter customization by overriding filterTermAccessor, + * properties are accessed. Also allows for filter customization by overriding filterPredicate, * which defines how row data is converted to a string for filter matching. * * **Note:** This class is meant to be a simple data source to help you get started. As such diff --git a/src/material/table/table-data-source.ts b/src/material/table/table-data-source.ts index 318eaa83b76b..f6d03924afb6 100644 --- a/src/material/table/table-data-source.ts +++ b/src/material/table/table-data-source.ts @@ -310,12 +310,12 @@ export class _MatTableDataSource< /** * Returns a filtered data array where each filter object contains the filter string within - * the result of the filterTermAccessor function. If no filter is set, returns the data array + * the result of the filterPredicate function. If no filter is set, returns the data array * as provided. */ _filterData(data: T[]) { // If there is a filter string, filter out data that does not contain it. - // Each data object is converted to a string using the function defined by filterTermAccessor. + // Each data object is converted to a string using the function defined by filterPredicate. // May be overridden for customization. this.filteredData = this.filter == null || this.filter === '' @@ -414,7 +414,7 @@ export class _MatTableDataSource< * sorting (using MatSort), and pagination (using MatPaginator). * * Allows for sort customization by overriding sortingDataAccessor, which defines how data - * properties are accessed. Also allows for filter customization by overriding filterTermAccessor, + * properties are accessed. Also allows for filter customization by overriding filterPredicate, * which defines how row data is converted to a string for filter matching. * * **Note:** This class is meant to be a simple data source to help you get started. As such From b00bf81704f13b847e71f39e6570521f811f8127 Mon Sep 17 00:00:00 2001 From: Zach Arend Date: Thu, 13 Apr 2023 16:33:25 +0000 Subject: [PATCH 3/3] release: cut the v15.2.7 release --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12beb5aa63ab..a482fb73ffd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ + +# 15.2.7 "paper-pelican" (2023-04-13) +### material +| Commit | Type | Description | +| -- | -- | -- | +| [de22cdc72](https://github.com/angular/components/commit/de22cdc7227187ad11e385caf0456639cfea1da8) | fix | **table:** correct filterPredicate typo ([#26902](https://github.com/angular/components/pull/26902)) | +### material-luxon-adapter +| Commit | Type | Description | +| -- | -- | -- | +| [6c00403a8](https://github.com/angular/components/commit/6c00403a874dd3132de6995d4dcd9e4ebf9dfb82) | fix | zone on DateTime ignored ([#26887](https://github.com/angular/components/pull/26887)) | + + + # 15.2.6 "chiffon-cardigan" (2023-04-05) ### cdk diff --git a/package.json b/package.json index 3c72c6d19897..ad1a875eee79 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "ci-notify-slack-failure": "ts-node --esm --project scripts/tsconfig.json scripts/circleci/notify-slack-job-failure.mts", "prepare": "husky install" }, - "version": "15.2.6", + "version": "15.2.7", "dependencies": { "@angular/animations": "^15.2.0-rc.0", "@angular/common": "^15.2.0-rc.0",