From 4ac5c85f3d4716ffd6d1a858231801519ed0062f Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Tue, 17 Oct 2017 11:14:09 -0700 Subject: [PATCH 1/2] fix(datepicker): correct DST issues on IE 11 --- src/lib/core/datetime/native-date-adapter.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/core/datetime/native-date-adapter.ts b/src/lib/core/datetime/native-date-adapter.ts index 22fd954693b2..40c0c15e3ec8 100644 --- a/src/lib/core/datetime/native-date-adapter.ts +++ b/src/lib/core/datetime/native-date-adapter.ts @@ -6,6 +6,7 @@ * 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'; @@ -60,18 +61,21 @@ function range(length: number, valueFunction: (index: number) => T): T[] { /** Adapts the native JS Date for use with cdk-based components that work with dates. */ @Injectable() export class NativeDateAdapter extends DateAdapter { - constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string) { - super(); - super.setLocale(matDateLocale); - } - /** * Whether to use `timeZone: 'utc'` with `Intl.DateTimeFormat` when formatting dates. * Without this `Intl.DateTimeFormat` sometimes chooses the wrong timeZone, which can throw off * the result. (e.g. in the en-US locale `new Date(1800, 7, 14).toLocaleDateString()` * will produce `'8/13/1800'`. */ - useUtcForDisplay = true; + useUtcForDisplay: boolean; + + constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string, platform: Platform) { + super(); + super.setLocale(matDateLocale); + + // IE does its own time zone correction, so we disable this on IE. + this.useUtcForDisplay = !platform.TRIDENT; + } getYear(date: Date): number { return date.getFullYear(); From b2701e173bf686ea17e148e4da037912cf8984a8 Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Tue, 17 Oct 2017 12:18:04 -0700 Subject: [PATCH 2/2] fix tests --- src/lib/core/datetime/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/core/datetime/index.ts b/src/lib/core/datetime/index.ts index 0059b79b50bc..e5ef807f498a 100644 --- a/src/lib/core/datetime/index.ts +++ b/src/lib/core/datetime/index.ts @@ -6,10 +6,11 @@ * 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 {NativeDateAdapter} from './native-date-adapter'; import {MAT_DATE_FORMATS} from './date-formats'; +import {NativeDateAdapter} from './native-date-adapter'; import {MAT_NATIVE_DATE_FORMATS} from './native-date-formats'; export * from './date-adapter'; @@ -19,6 +20,7 @@ export * from './native-date-formats'; @NgModule({ + imports: [PlatformModule], providers: [ {provide: DateAdapter, useClass: NativeDateAdapter}, MAT_DATE_LOCALE_PROVIDER