|
9 | 9 | import {LOCALE_ID} from '@angular/core';
|
10 | 10 | import {TestBed, waitForAsync} from '@angular/core/testing';
|
11 | 11 | import {DateAdapter, MAT_DATE_LOCALE} from '@angular/material/core';
|
12 |
| -import {DateTime} from 'luxon'; |
| 12 | +import {DateTime, FixedOffsetZone, Settings} from 'luxon'; |
13 | 13 | import {LuxonDateModule} from './index';
|
14 | 14 | import {MAT_LUXON_DATE_ADAPTER_OPTIONS} from './luxon-date-adapter';
|
15 | 15 |
|
@@ -351,6 +351,16 @@ describe('LuxonDateAdapter', () => {
|
351 | 351 | expect(date).toEqual('2. jan. 2017');
|
352 | 352 | });
|
353 | 353 |
|
| 354 | + it('should format with a different timezone', () => { |
| 355 | + Settings.defaultZone = FixedOffsetZone.parseSpecifier('UTC-12'); |
| 356 | + |
| 357 | + let date = adapter.format(DateTime.local(2017, JAN, 2, {zone: 'UTC-12'}), 'DD'); |
| 358 | + expect(date).toEqual('Jan 2, 2017'); |
| 359 | + |
| 360 | + date = adapter.format(DateTime.local(2017, JAN, 2, {zone: 'UTC+12'}), 'DD'); |
| 361 | + expect(date).toEqual('Jan 2, 2017'); |
| 362 | + }); |
| 363 | + |
354 | 364 | it('should throw when attempting to format invalid date', () => {
|
355 | 365 | expect(() => adapter.format(DateTime.fromMillis(NaN), 'LL/dd/yyyy')).toThrowError(
|
356 | 366 | /LuxonDateAdapter: Cannot format invalid date\./,
|
|
0 commit comments