Skip to content

cleanup(datepicker): undo breaking change to NativeDateAdapter #8281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2017
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
2 changes: 0 additions & 2 deletions src/lib/core/datetime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -20,7 +19,6 @@ export * from './native-date-formats';


@NgModule({
imports: [PlatformModule],
providers: [
{provide: DateAdapter, useClass: NativeDateAdapter},
MAT_DATE_LOCALE_PROVIDER
Expand Down
8 changes: 5 additions & 3 deletions src/lib/core/datetime/native-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -69,12 +68,15 @@ export class NativeDateAdapter extends DateAdapter<Date> {
*/
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 {
Expand Down