|
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 {DateAdapter, MAT_DATE_LOCALE} from './date-adapter';
|
11 | 12 |
|
@@ -67,20 +68,15 @@ export class NativeDateAdapter extends DateAdapter<Date> {
|
67 | 68 | * the result. (e.g. in the en-US locale `new Date(1800, 7, 14).toLocaleDateString()`
|
68 | 69 | * will produce `'8/13/1800'`.
|
69 | 70 | */
|
70 |
| - useUtcForDisplay: boolean; |
| 71 | + useUtcForDisplay: boolean = true; |
71 | 72 |
|
72 |
| - constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string) { |
| 73 | + constructor(@Optional() @Inject(MAT_DATE_LOCALE) matDateLocale: string, platform: Platform) { |
73 | 74 | super();
|
74 | 75 | super.setLocale(matDateLocale);
|
75 | 76 |
|
76 | 77 | // IE does its own time zone correction, so we disable this on IE.
|
77 |
| - // TODO(mmalerba): replace with checks from PLATFORM, logic currently duplicated to avoid |
78 |
| - // breaking change from injecting the Platform. |
79 |
| - const isBrowser = typeof document === 'object' && !!document; |
80 |
| - const isIE = isBrowser && /(msie|trident)/i.test(navigator.userAgent); |
81 |
| - |
82 |
| - this.useUtcForDisplay = !isIE; |
83 |
| - this._clampDate = isIE || (isBrowser && /(edge)/i.test(navigator.userAgent)); |
| 78 | + this.useUtcForDisplay = !platform.TRIDENT; |
| 79 | + this._clampDate = platform.TRIDENT || platform.EDGE; |
84 | 80 | }
|
85 | 81 |
|
86 | 82 | getYear(date: Date): number {
|
|
0 commit comments