| Index: tests/corelib/date_time_test.dart
|
| diff --git a/tests/corelib/date_time_test.dart b/tests/corelib/date_time_test.dart
|
| index b81201a8b6290df0e8448e5cf8ffdf4acc6cd12f..fd952c541f18a899305664ba5963c06d56bea549 100644
|
| --- a/tests/corelib/date_time_test.dart
|
| +++ b/tests/corelib/date_time_test.dart
|
| @@ -22,12 +22,12 @@ class DateTest {
|
| static void testValue() {
|
| var dt1 = new Date.now();
|
| var value = dt1.value;
|
| - var dt2 = new Date.fromEpoch(value, new TimeZone.local());
|
| + var dt2 = new Date.fromEpoch(value);
|
| Expect.equals(value, dt2.value);
|
| }
|
|
|
| static void testFarAwayDates() {
|
| - Date dt = new Date.fromEpoch(1000000000000001, const TimeZone.utc());
|
| + Date dt = new Date.fromEpoch(1000000000000001, isUtc: true);
|
| Expect.equals(33658, dt.year);
|
| Expect.equals(9, dt.month);
|
| Expect.equals(27, dt.day);
|
| @@ -35,7 +35,7 @@ class DateTest {
|
| Expect.equals(46, dt.minutes);
|
| Expect.equals(40, dt.seconds);
|
| Expect.equals(1, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-1000000000000001, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-1000000000000001, isUtc: true);
|
| Expect.equals(-29719, dt.year);
|
| Expect.equals(4, dt.month);
|
| Expect.equals(5, dt.day);
|
| @@ -44,7 +44,7 @@ class DateTest {
|
| Expect.equals(19, dt.seconds);
|
| Expect.equals(999, dt.milliseconds);
|
| // Same with local zone.
|
| - dt = new Date.fromEpoch(1000000000000001, new TimeZone.local());
|
| + dt = new Date.fromEpoch(1000000000000001);
|
| Expect.equals(33658, dt.year);
|
| Expect.equals(9, dt.month);
|
| Expect.equals(true, dt.day == 27 || dt.day == 26);
|
| @@ -54,7 +54,7 @@ class DateTest {
|
| Expect.equals(true, dt.minutes % 15 == 46 % 15);
|
| Expect.equals(40, dt.seconds);
|
| Expect.equals(1, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-1000000000000001, new TimeZone.local());
|
| + dt = new Date.fromEpoch(-1000000000000001);
|
| Expect.equals(-29719, dt.year);
|
| Expect.equals(4, dt.month);
|
| Expect.equals(true, 5 == dt.day || 6 == dt.day);
|
| @@ -70,7 +70,7 @@ class DateTest {
|
| // All hardcoded values come from V8. This means that the values are not
|
| // necessarily correct (see limitations of Date object in
|
| // EcmaScript 15.9.1 and in particular 15.9.1.8/9).
|
| - Date dt = new Date.fromEpoch(-31485600000, const TimeZone.utc());
|
| + Date dt = new Date.fromEpoch(-31485600000, isUtc: true);
|
| Expect.equals(1969, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -78,7 +78,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-63108000000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-63108000000, isUtc: true);
|
| Expect.equals(1968, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -86,7 +86,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-94644000000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-94644000000, isUtc: true);
|
| Expect.equals(1967, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -94,7 +94,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-126180000000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-126180000000, isUtc: true);
|
| Expect.equals(1966, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -102,7 +102,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-157716000000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-157716000000, isUtc: true);
|
| Expect.equals(1965, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -110,7 +110,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-2177402400000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-2177402400000, isUtc: true);
|
| Expect.equals(1901, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -118,7 +118,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-5333076000000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-5333076000000, isUtc: true);
|
| Expect.equals(1801, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -126,7 +126,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-8520285600000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-8520285600000, isUtc: true);
|
| Expect.equals(1700, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -134,7 +134,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-14831719200000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-14831719200000, isUtc: true);
|
| Expect.equals(1500, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -142,7 +142,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-59011408800000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-59011408800000, isUtc: true);
|
| Expect.equals(100, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -150,7 +150,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-62011408800000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-62011408800000, isUtc: true);
|
| Expect.equals(4, dt.year);
|
| Expect.equals(12, dt.month);
|
| Expect.equals(8, dt.day);
|
| @@ -158,7 +158,7 @@ class DateTest {
|
| Expect.equals(40, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - dt = new Date.fromEpoch(-64011408800000, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-64011408800000, isUtc: true);
|
| Expect.equals(-59, dt.year);
|
| Expect.equals(7, dt.month);
|
| Expect.equals(24, dt.day);
|
| @@ -167,7 +167,7 @@ class DateTest {
|
| Expect.equals(40, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| final int SECONDS_YEAR_2035 = 2051222400;
|
| - dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1, isUtc: true);
|
| Expect.equals(2035, dt.year);
|
| Expect.equals(1, dt.month);
|
| Expect.equals(1, dt.day);
|
| @@ -175,7 +175,7 @@ class DateTest {
|
| Expect.equals(0, dt.minutes);
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(1, dt.milliseconds);
|
| - dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1, isUtc: true);
|
| Expect.equals(2034, dt.year);
|
| Expect.equals(12, dt.month);
|
| Expect.equals(31, dt.day);
|
| @@ -183,33 +183,32 @@ class DateTest {
|
| Expect.equals(59, dt.minutes);
|
| Expect.equals(59, dt.seconds);
|
| Expect.equals(999, dt.milliseconds);
|
| - dt = new Date.withTimeZone(2035, 1, 1, 0, 0, 0, 1, const TimeZone.utc());
|
| + dt = new Date(2035, 1, 1, 0, 0, 0, 1, isUtc: true);
|
| Expect.equals(SECONDS_YEAR_2035 * 1000 + 1, dt.value);
|
| - dt = new Date.withTimeZone(2034, 12, 31, 23, 59, 59, 999,
|
| - const TimeZone.utc());
|
| + dt = new Date(2034, 12, 31, 23, 59, 59, 999, isUtc: true);
|
| Expect.equals(SECONDS_YEAR_2035 * 1000 - 1, dt.value);
|
| - dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1, new TimeZone.local());
|
| + dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1);
|
| Expect.equals(true, (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
|
| (2034 == dt.year && 12 == dt.month && 31 == dt.day));
|
| Expect.equals(0, dt.seconds);
|
| Expect.equals(1, dt.milliseconds);
|
| - Date dt2 = new Date.withTimeZone(
|
| + Date dt2 = new Date(
|
| dt.year, dt.month, dt.day, dt.hours, dt.minutes, dt.seconds,
|
| - dt.milliseconds, new TimeZone.local());
|
| + dt.milliseconds);
|
| Expect.equals(dt.value, dt2.value);
|
| - dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1, new TimeZone.local());
|
| + dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1);
|
| Expect.equals(true, (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
|
| (2034 == dt.year && 12 == dt.month && 31 == dt.day));
|
| Expect.equals(59, dt.seconds);
|
| Expect.equals(999, dt.milliseconds);
|
| - dt2 = new Date.withTimeZone(
|
| + dt2 = new Date(
|
| dt.year, dt.month, dt.day, dt.hours, dt.minutes, dt.seconds,
|
| - dt.milliseconds, new TimeZone.local());
|
| + dt.milliseconds);
|
| Expect.equals(dt.value, dt2.value);
|
| }
|
|
|
| static void testUTCGetters() {
|
| - var dt = new Date.fromEpoch(1305140315000, const TimeZone.utc());
|
| + var dt = new Date.fromEpoch(1305140315000, isUtc: true);
|
| Expect.equals(2011, dt.year);
|
| Expect.equals(5, dt.month);
|
| Expect.equals(11, dt.day);
|
| @@ -217,9 +216,9 @@ class DateTest {
|
| Expect.equals(58, dt.minutes);
|
| Expect.equals(35, dt.seconds);
|
| Expect.equals(0, dt.milliseconds);
|
| - Expect.equals(true, const TimeZone.utc() == dt.timeZone);
|
| + Expect.equals(true, dt.isUtc());
|
| Expect.equals(1305140315000, dt.value);
|
| - dt = new Date.fromEpoch(-9999999, const TimeZone.utc());
|
| + dt = new Date.fromEpoch(-9999999, isUtc: true);
|
| Expect.equals(1969, dt.year);
|
| Expect.equals(12, dt.month);
|
| Expect.equals(31, dt.day);
|
| @@ -230,11 +229,11 @@ class DateTest {
|
| }
|
|
|
| static void testLocalGetters() {
|
| - var dt1 = new Date.fromEpoch(1305140315000, new TimeZone.local());
|
| - var dt2 = new Date.withTimeZone(dt1.year, dt1.month, dt1.day,
|
| - dt1.hours, dt1.minutes, dt1.seconds,
|
| - dt1.milliseconds,
|
| - const TimeZone.utc());
|
| + var dt1 = new Date.fromEpoch(1305140315000);
|
| + var dt2 = new Date(dt1.year, dt1.month, dt1.day,
|
| + dt1.hours, dt1.minutes, dt1.seconds,
|
| + dt1.milliseconds,
|
| + isUtc: true);
|
| Duration zoneOffset = dt1.difference(dt2);
|
| Expect.equals(true, zoneOffset.inDays == 0);
|
| Expect.equals(true, zoneOffset.inHours.abs() <= 12);
|
| @@ -252,33 +251,29 @@ class DateTest {
|
| }
|
|
|
| static void testConstructors() {
|
| - var dt1 = new Date.fromEpoch(1305140315000, new TimeZone.local());
|
| + var dt1 = new Date.fromEpoch(1305140315000);
|
| var dt3 = new Date(dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
|
| dt1.seconds, dt1.milliseconds);
|
| Expect.equals(dt1.value, dt3.value);
|
| Expect.equals(true, dt1 == dt3);
|
| - dt3 = new Date.withTimeZone(
|
| + dt3 = new Date(
|
| dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
|
| - dt1.seconds, dt1.milliseconds, new TimeZone.local());
|
| + dt1.seconds, dt1.milliseconds);
|
| Expect.equals(dt1.value, dt3.value);
|
| Expect.equals(true, dt1 == dt3);
|
| - dt3 = new Date.withTimeZone(2011, 5, 11, 18, 58, 35, 0,
|
| - const TimeZone.utc());
|
| + dt3 = new Date(2011, 5, 11, 18, 58, 35, 0, isUtc: true);
|
| Expect.equals(dt1.value, dt3.value);
|
| - Expect.equals(false, dt1 == dt3);
|
| - var dt2 = dt1.changeTimeZone(new TimeZone.local());
|
| - dt3 = new Date.withTimeZone(2011, 5, dt1.day,
|
| - dt1.hours, dt1.minutes, 35, 0,
|
| - new TimeZone.local());
|
| + Expect.equals(true, dt1 == dt3);
|
| + var dt2 = dt1.toLocal();
|
| + dt3 = new Date(2011, 5, dt1.day, dt1.hours, dt1.minutes, 35, 0);
|
| Expect.equals(dt2.value, dt3.value);
|
| Expect.equals(true, dt2 == dt3);
|
| - dt1 = new Date.fromEpoch(-9999999, const TimeZone.utc());
|
| - dt3 = new Date.withTimeZone(
|
| + dt1 = new Date.fromEpoch(-9999999, isUtc: true);
|
| + dt3 = new Date(
|
| dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
|
| - dt1.seconds, dt1.milliseconds, const TimeZone.utc());
|
| + dt1.seconds, dt1.milliseconds, isUtc: true);
|
| Expect.equals(dt1.value, dt3.value);
|
| - dt3 = new Date.withTimeZone(99, 1, 2, 10, 11, 12, 0,
|
| - const TimeZone.utc());
|
| + dt3 = new Date(99, 1, 2, 10, 11, 12, 0, isUtc: true);
|
| Expect.equals(99, dt3.year);
|
| Expect.equals(1, dt3.month);
|
| Expect.equals(2, dt3.day);
|
| @@ -290,10 +285,10 @@ class DateTest {
|
| }
|
|
|
| static void testChangeTimeZone() {
|
| - var dt1 = new Date.fromEpoch(1305140315000, new TimeZone.local());
|
| - var dt2 = dt1.changeTimeZone(const TimeZone.utc());
|
| + var dt1 = new Date.fromEpoch(1305140315000);
|
| + var dt2 = dt1.toUtc();
|
| Expect.equals(dt1.value, dt2.value);
|
| - var dt3 = new Date.fromEpoch(1305140315000, const TimeZone.utc());
|
| + var dt3 = new Date.fromEpoch(1305140315000, isUtc: true);
|
| Expect.equals(dt1.value, dt3.value);
|
| Expect.equals(dt2.year, dt3.year);
|
| Expect.equals(dt2.month, dt3.month);
|
| @@ -302,7 +297,7 @@ class DateTest {
|
| Expect.equals(dt2.minutes, dt3.minutes);
|
| Expect.equals(dt2.seconds, dt3.seconds);
|
| Expect.equals(dt2.milliseconds, dt3.milliseconds);
|
| - var dt4 = dt3.changeTimeZone(new TimeZone.local());
|
| + var dt4 = dt3.toLocal();
|
| Expect.equals(dt1.year, dt4.year);
|
| Expect.equals(dt1.month, dt4.month);
|
| Expect.equals(dt1.day, dt4.day);
|
| @@ -313,7 +308,7 @@ class DateTest {
|
| }
|
|
|
| static void testSubAdd() {
|
| - var dt1 = new Date.fromEpoch(1305140315000, const TimeZone.utc());
|
| + var dt1 = new Date.fromEpoch(1305140315000, isUtc: true);
|
| var dt2 = dt1.add(new Duration(milliseconds:
|
| 3 * Duration.MILLISECONDS_PER_SECOND + 5));
|
| Expect.equals(dt1.year, dt2.year);
|
| @@ -343,7 +338,7 @@ class DateTest {
|
| var str = dt1.toString();
|
| var dt2 = new Date.fromString(str);
|
| Expect.equals(true, dt1 == dt2);
|
| - var dt3 = dt1.changeTimeZone(const TimeZone.utc());
|
| + var dt3 = dt1.toUtc();
|
| str = dt3.toString();
|
| Expect.equals("2011-05-11 18:58:35.000Z", str);
|
| var dt4 = new Date.fromString("-1234-01-01 00:00:00Z");
|
| @@ -503,19 +498,18 @@ class DateTest {
|
| // 2011-10-06 is Summertime.
|
| var d = new Date(2011, 10, 6, 0, 45, 37, 0);
|
| Expect.equals(Date.THU, d.weekday);
|
| - d = new Date.withTimeZone(2011, 10, 6, 0, 45, 37, 0, const TimeZone.utc());
|
| + d = new Date(2011, 10, 6, 0, 45, 37, 0, isUtc: true);
|
| Expect.equals(Date.THU, d.weekday);
|
| d = new Date(2011, 10, 5, 23, 45, 37, 0);
|
| Expect.equals(Date.WED, d.weekday);
|
| - d = new Date.withTimeZone(2011, 10, 5, 23, 45, 37, 0, const TimeZone.utc());
|
| + d = new Date(2011, 10, 5, 23, 45, 37, 0, isUtc: true);
|
| Expect.equals(Date.WED, d.weekday);
|
| // 1970-01-01 is Wintertime.
|
| d = new Date(1970, 1, 1, 0, 0, 0, 1);
|
| Expect.equals(Date.THU, d.weekday);
|
| - d = new Date.withTimeZone(1970, 1, 1, 0, 0, 0, 1, const TimeZone.utc());
|
| + d = new Date(1970, 1, 1, 0, 0, 0, 1, isUtc: true);
|
| Expect.equals(Date.THU, d.weekday);
|
| - d = new Date.withTimeZone(1969, 12, 31, 23, 59, 59, 999,
|
| - const TimeZone.utc());
|
| + d = new Date(1969, 12, 31, 23, 59, 59, 999, isUtc: true);
|
| Expect.equals(Date.WED, d.weekday);
|
| d = new Date(1969, 12, 31, 23, 59, 59, 999);
|
| Expect.equals(Date.WED, d.weekday);
|
|
|