Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: tests/corelib/date_time7_test.dart

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and keep Backwards-compatibility class Date. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/corelib/date_time6_test.dart ('k') | tests/corelib/date_time8_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test Date timeZoneName and timeZoneOffset getters. 5 // Test DateTime timeZoneName and timeZoneOffset getters.
6 6
7 testUtc() { 7 testUtc() {
8 var d = new Date.fromString("2012-03-04T03:25:38.123Z"); 8 var d = new DateTime.fromString("2012-03-04T03:25:38.123Z");
9 Expect.equals("UTC", d.timeZoneName); 9 Expect.equals("UTC", d.timeZoneName);
10 Expect.equals(0, d.timeZoneOffset.inSeconds); 10 Expect.equals(0, d.timeZoneOffset.inSeconds);
11 } 11 }
12 12
13 testLocal() { 13 testLocal() {
14 checkOffset(String name, Duration offset) { 14 checkOffset(String name, Duration offset) {
15 // Timezone abbreviations are not in bijection with their timezones. 15 // Timezone abbreviations are not in bijection with their timezones.
16 // For example AST stands for "Arab Standard Time" (UTC+03), as well as 16 // For example AST stands for "Arab Standard Time" (UTC+03), as well as
17 // "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time 17 // "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time
18 // and Philippine Standard Time. 18 // and Philippine Standard Time.
19 // 19 //
20 // Hardcode some common timezones. 20 // Hardcode some common timezones.
21 if (name == "CET") { 21 if (name == "CET") {
22 Expect.equals(1, offset.inHours); 22 Expect.equals(1, offset.inHours);
23 } else if (name == "CEST") { 23 } else if (name == "CEST") {
24 Expect.equals(2, offset.inHours); 24 Expect.equals(2, offset.inHours);
25 } else if (name == "GMT") { 25 } else if (name == "GMT") {
26 Expect.equals(0, offset.inSeconds); 26 Expect.equals(0, offset.inSeconds);
27 } else if (name == "EST") { 27 } else if (name == "EST") {
28 Expect.equals(-5, offset.inHours); 28 Expect.equals(-5, offset.inHours);
29 } else if (name == "EDT") { 29 } else if (name == "EDT") {
30 Expect.equals(-4, offset.inHours); 30 Expect.equals(-4, offset.inHours);
31 } else if (name == "PDT") { 31 } else if (name == "PDT") {
32 Expect.equals(-7, offset.inHours); 32 Expect.equals(-7, offset.inHours);
33 } 33 }
34 } 34 }
35 35
36 var d = new Date.fromString("2012-01-02T13:45:23"); 36 var d = new DateTime.fromString("2012-01-02T13:45:23");
37 String name = d.timeZoneName; 37 String name = d.timeZoneName;
38 checkOffset(name, d.timeZoneOffset); 38 checkOffset(name, d.timeZoneOffset);
39 39
40 d = new Date.fromString("2012-07-02T13:45:23"); 40 d = new DateTime.fromString("2012-07-02T13:45:23");
41 name = d.timeZoneName; 41 name = d.timeZoneName;
42 checkOffset(name, d.timeZoneOffset); 42 checkOffset(name, d.timeZoneOffset);
43 } 43 }
44 44
45 main() { 45 main() {
46 testUtc(); 46 testUtc();
47 testLocal(); 47 testLocal();
48 } 48 }
OLDNEW
« no previous file with comments | « tests/corelib/date_time6_test.dart ('k') | tests/corelib/date_time8_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698