alanknight | e675642 | 2017-10-31 10:30:12 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | /// Test date formatting and parsing using locale data directly imported. |
| 6 | /// |
| 7 | /// This is a copy of date_time_format_local_even_test.dart which also |
| 8 | /// verifies the time zone against an environment variable. |
| 9 | |
| 10 | import 'dart:io'; |
| 11 | |
alanknight | e675642 | 2017-10-31 10:30:12 -0700 | [diff] [blame] | 12 | import 'package:intl/date_symbol_data_local.dart'; |
| 13 | import 'package:test/test.dart'; |
| 14 | |
Dart Team | 795c490 | 2019-08-29 10:58:28 -0700 | [diff] [blame] | 15 | import 'date_time_format_test_stub.dart'; |
| 16 | |
| 17 | void main() { |
alanknight | e675642 | 2017-10-31 10:30:12 -0700 | [diff] [blame] | 18 | var tzOffset = Platform.environment['EXPECTED_TZ_OFFSET_FOR_TEST']; |
| 19 | var timezoneName = Platform.environment['TZ']; |
| 20 | if (tzOffset != null) { |
Dart Team | 795c490 | 2019-08-29 10:58:28 -0700 | [diff] [blame] | 21 | test('Actually running in the correct time zone: $timezoneName', () { |
alanknight | e675642 | 2017-10-31 10:30:12 -0700 | [diff] [blame] | 22 | // Pick a constant Date so that the offset is known. |
Dart Team | 795c490 | 2019-08-29 10:58:28 -0700 | [diff] [blame] | 23 | var d = DateTime(2012, 1, 1, 7, 6, 5); |
| 24 | print('Time zone offset is ${d.timeZoneOffset.inHours}'); |
| 25 | print('Time zone name is ${d.timeZoneName}'); |
alanknight | e675642 | 2017-10-31 10:30:12 -0700 | [diff] [blame] | 26 | expect(tzOffset, '${d.timeZoneOffset.inHours}'); |
| 27 | }); |
| 28 | } |
| 29 | |
| 30 | // Run the main date formatting tests with a large set of locales. |
| 31 | runWith(evenLocales, null, initializeDateFormatting); |
| 32 | } |