|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +import {Platform} from '@angular/cdk/platform'; |
9 | 10 | import {Inject, Injectable, Optional} from '@angular/core';
|
10 | 11 | import {extendObject} from '../util/object-extend';
|
11 | 12 | import {DateAdapter, MAT_DATE_LOCALE} from './date-adapter';
|
@@ -60,18 +61,21 @@ function range<T>(length: number, valueFunction: (index: number) => T): T[] {
|
60 | 61 | /** Adapts the native JS Date for use with cdk-based components that work with dates. */
|
61 | 62 | @Injectable()
|
62 | 63 | export class NativeDateAdapter extends DateAdapter<Date> {
|
63 |
| - constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string) { |
64 |
| - super(); |
65 |
| - super.setLocale(matDateLocale); |
66 |
| - } |
67 |
| - |
68 | 64 | /**
|
69 | 65 | * Whether to use `timeZone: 'utc'` with `Intl.DateTimeFormat` when formatting dates.
|
70 | 66 | * Without this `Intl.DateTimeFormat` sometimes chooses the wrong timeZone, which can throw off
|
71 | 67 | * the result. (e.g. in the en-US locale `new Date(1800, 7, 14).toLocaleDateString()`
|
72 | 68 | * will produce `'8/13/1800'`.
|
73 | 69 | */
|
74 |
| - useUtcForDisplay = true; |
| 70 | + useUtcForDisplay: boolean; |
| 71 | + |
| 72 | + constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string, platform: Platform) { |
| 73 | + super(); |
| 74 | + super.setLocale(matDateLocale); |
| 75 | + |
| 76 | + // IE does its own time zone correction, so we disable this on IE. |
| 77 | + this.useUtcForDisplay = !platform.TRIDENT; |
| 78 | + } |
75 | 79 |
|
76 | 80 | getYear(date: Date): number {
|
77 | 81 | return date.getFullYear();
|
|
0 commit comments