Skip to content

Commit 8b3c8a5

Browse files
mmalerbajosephperrott
authored andcommitted
cleanup(datepicker): undo breaking change to NativeDateAdapter (#8281)
1 parent 998153a commit 8b3c8a5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/lib/core/datetime/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {PlatformModule} from '@angular/cdk/platform';
109
import {NgModule} from '@angular/core';
1110
import {DateAdapter, MAT_DATE_LOCALE_PROVIDER} from './date-adapter';
1211
import {MAT_DATE_FORMATS} from './date-formats';
@@ -20,7 +19,6 @@ export * from './native-date-formats';
2019

2120

2221
@NgModule({
23-
imports: [PlatformModule],
2422
providers: [
2523
{provide: DateAdapter, useClass: NativeDateAdapter},
2624
MAT_DATE_LOCALE_PROVIDER

src/lib/core/datetime/native-date-adapter.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Platform} from '@angular/cdk/platform';
109
import {Inject, Injectable, Optional} from '@angular/core';
1110
import {extendObject} from '../util/object-extend';
1211
import {DateAdapter, MAT_DATE_LOCALE} from './date-adapter';
@@ -69,12 +68,15 @@ export class NativeDateAdapter extends DateAdapter<Date> {
6968
*/
7069
useUtcForDisplay: boolean;
7170

72-
constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string, platform: Platform) {
71+
constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string) {
7372
super();
7473
super.setLocale(matDateLocale);
7574

7675
// IE does its own time zone correction, so we disable this on IE.
77-
this.useUtcForDisplay = !platform.TRIDENT;
76+
// TODO(mmalerba): replace with !platform.TRIDENT, logic currently duplicated to avoid breaking
77+
// change from injecting the Platform.
78+
this.useUtcForDisplay = !(typeof document === 'object' && !!document &&
79+
/(msie|trident)/i.test(navigator.userAgent));
7880
}
7981

8082
getYear(date: Date): number {

0 commit comments

Comments
 (0)