From 8b3c8a5873aa6f7501f275c185addb8af7d374e2 Mon Sep 17 00:00:00 2001 From: mmalerba Date: Tue, 7 Nov 2017 11:32:47 -0800 Subject: [PATCH] cleanup(datepicker): undo breaking change to `NativeDateAdapter` (#8281) --- src/lib/core/datetime/index.ts | 2 -- src/lib/core/datetime/native-date-adapter.ts | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/core/datetime/index.ts b/src/lib/core/datetime/index.ts index e5ef807f498..9a8895841fe 100644 --- a/src/lib/core/datetime/index.ts +++ b/src/lib/core/datetime/index.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {PlatformModule} from '@angular/cdk/platform'; import {NgModule} from '@angular/core'; import {DateAdapter, MAT_DATE_LOCALE_PROVIDER} from './date-adapter'; import {MAT_DATE_FORMATS} from './date-formats'; @@ -20,7 +19,6 @@ export * from './native-date-formats'; @NgModule({ - imports: [PlatformModule], providers: [ {provide: DateAdapter, useClass: NativeDateAdapter}, MAT_DATE_LOCALE_PROVIDER diff --git a/src/lib/core/datetime/native-date-adapter.ts b/src/lib/core/datetime/native-date-adapter.ts index 40c0c15e3ec..4b9b9af4624 100644 --- a/src/lib/core/datetime/native-date-adapter.ts +++ b/src/lib/core/datetime/native-date-adapter.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {Platform} from '@angular/cdk/platform'; import {Inject, Injectable, Optional} from '@angular/core'; import {extendObject} from '../util/object-extend'; import {DateAdapter, MAT_DATE_LOCALE} from './date-adapter'; @@ -69,12 +68,15 @@ export class NativeDateAdapter extends DateAdapter { */ useUtcForDisplay: boolean; - constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string, platform: Platform) { + constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string) { super(); super.setLocale(matDateLocale); // IE does its own time zone correction, so we disable this on IE. - this.useUtcForDisplay = !platform.TRIDENT; + // TODO(mmalerba): replace with !platform.TRIDENT, logic currently duplicated to avoid breaking + // change from injecting the Platform. + this.useUtcForDisplay = !(typeof document === 'object' && !!document && + /(msie|trident)/i.test(navigator.userAgent)); } getYear(date: Date): number {