Index: test/codegen/expect/corelib/date_time_test.js |
diff --git a/test/codegen/expect/corelib/date_time_test.js b/test/codegen/expect/corelib/date_time_test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9384f0dcd55b174604f2f27b3aed9f26acd523ff |
--- /dev/null |
+++ b/test/codegen/expect/corelib/date_time_test.js |
@@ -0,0 +1,1201 @@ |
+dart_library.library('corelib/date_time_test', null, /* Imports */[ |
+ 'dart_sdk', |
+ 'expect' |
+], function load__date_time_test(exports, dart_sdk, expect) { |
+ 'use strict'; |
+ const core = dart_sdk.core; |
+ const dart = dart_sdk.dart; |
+ const dartx = dart_sdk.dartx; |
+ const expect$ = expect.expect; |
+ const date_time_test = Object.create(null); |
+ let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [])))(); |
+ let VoidToDateTime = () => (VoidToDateTime = dart.constFn(dart.definiteFunctionType(core.DateTime, [])))(); |
+ let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionType(core.bool, [dart.dynamic])))(); |
+ let dynamicAnddynamicTovoid = () => (dynamicAnddynamicTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [dart.dynamic, dart.dynamic])))(); |
+ dart.copyProperties(date_time_test, { |
+ get supportsMicroseconds() { |
+ return new core.DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; |
+ } |
+ }); |
+ date_time_test._MAX_MILLISECONDS = 8640000000000000; |
+ date_time_test.testNow = function() { |
+ let t1 = new core.DateTime.now(); |
+ let timeMovedForward = false; |
+ let N = 1000000; |
+ outer: |
+ while (true) { |
+ for (let i = N; i > 0; i--) { |
+ let t2 = new core.DateTime.now(); |
+ if (dart.notNull(t1.millisecondsSinceEpoch) < dart.notNull(t2.millisecondsSinceEpoch)) { |
+ break outer; |
+ } |
+ } |
+ core.print(dart.str`testNow: No Date.now() progress in ${N} loops. Time: ${t1}`); |
+ } |
+ expect$.Expect.isFalse(t1.isUtc); |
+ }; |
+ dart.fn(date_time_test.testNow, VoidTovoid()); |
+ date_time_test.testMillisecondsSinceEpoch = function() { |
+ let dt1 = new core.DateTime.now(); |
+ let millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; |
+ let dt2 = new core.DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); |
+ expect$.Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
+ }; |
+ dart.fn(date_time_test.testMillisecondsSinceEpoch, VoidTovoid()); |
+ date_time_test.testMicrosecondsSinceEpoch = function() { |
+ let dt1 = new core.DateTime.fromMillisecondsSinceEpoch(1); |
+ let microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; |
+ let dt2 = new core.DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); |
+ expect$.Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); |
+ dt1 = new core.DateTime.now(); |
+ microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; |
+ dt2 = new core.DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); |
+ expect$.Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); |
+ }; |
+ dart.fn(date_time_test.testMicrosecondsSinceEpoch, VoidTovoid()); |
+ date_time_test.testFarAwayDates = function() { |
+ let dt = new core.DateTime.fromMillisecondsSinceEpoch(1000000000000001, {isUtc: true}); |
+ expect$.Expect.equals(33658, dt.year); |
+ expect$.Expect.equals(9, dt.month); |
+ expect$.Expect.equals(27, dt.day); |
+ expect$.Expect.equals(1, dt.hour); |
+ expect$.Expect.equals(46, dt.minute); |
+ expect$.Expect.equals(40, dt.second); |
+ expect$.Expect.equals(1, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-1000000000000001, {isUtc: true}); |
+ expect$.Expect.equals(-29719, dt.year); |
+ expect$.Expect.equals(4, dt.month); |
+ expect$.Expect.equals(5, dt.day); |
+ expect$.Expect.equals(22, dt.hour); |
+ expect$.Expect.equals(13, dt.minute); |
+ expect$.Expect.equals(19, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(1000000000000001); |
+ expect$.Expect.equals(33658, dt.year); |
+ expect$.Expect.equals(9, dt.month); |
+ expect$.Expect.equals(true, dt.day == 27 || dt.day == 26); |
+ expect$.Expect.equals(true, dart.notNull(dt.hour) >= 0 && dart.notNull(dt.hour) < 24); |
+ expect$.Expect.equals(true, dt.minute[dartx['%']](15) == (46)[dartx['%']](15)); |
+ expect$.Expect.equals(40, dt.second); |
+ expect$.Expect.equals(1, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-1000000000000001); |
+ expect$.Expect.equals(-29719, dt.year); |
+ expect$.Expect.equals(4, dt.month); |
+ expect$.Expect.equals(true, 5 == dt.day || 6 == dt.day); |
+ expect$.Expect.equals(true, dart.notNull(dt.hour) >= 0 && dart.notNull(dt.hour) < 24); |
+ expect$.Expect.equals(true, dt.minute[dartx['%']](15) == 13); |
+ expect$.Expect.equals(19, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(1000000000000000001, {isUtc: true}); |
+ expect$.Expect.equals(33658, dt.year); |
+ expect$.Expect.equals(9, dt.month); |
+ expect$.Expect.equals(27, dt.day); |
+ expect$.Expect.equals(1, dt.hour); |
+ expect$.Expect.equals(46, dt.minute); |
+ expect$.Expect.equals(40, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(1, dt.microsecond); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001, {isUtc: true}); |
+ expect$.Expect.equals(-29719, dt.year); |
+ expect$.Expect.equals(4, dt.month); |
+ expect$.Expect.equals(5, dt.day); |
+ expect$.Expect.equals(22, dt.hour); |
+ expect$.Expect.equals(13, dt.minute); |
+ expect$.Expect.equals(19, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(999, dt.microsecond); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(1000000000000000001); |
+ expect$.Expect.equals(33658, dt.year); |
+ expect$.Expect.equals(9, dt.month); |
+ expect$.Expect.equals(true, dt.day == 27 || dt.day == 26); |
+ expect$.Expect.equals(true, dart.notNull(dt.hour) >= 0 && dart.notNull(dt.hour) < 24); |
+ expect$.Expect.equals(true, dt.minute[dartx['%']](15) == (46)[dartx['%']](15)); |
+ expect$.Expect.equals(40, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(1, dt.microsecond); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001); |
+ expect$.Expect.equals(-29719, dt.year); |
+ expect$.Expect.equals(4, dt.month); |
+ expect$.Expect.equals(true, 5 == dt.day || 6 == dt.day); |
+ expect$.Expect.equals(true, dart.notNull(dt.hour) >= 0 && dart.notNull(dt.hour) < 24); |
+ expect$.Expect.equals(true, dt.minute[dartx['%']](15) == 13); |
+ expect$.Expect.equals(19, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(999, dt.microsecond); |
+ }; |
+ dart.fn(date_time_test.testFarAwayDates, VoidTovoid()); |
+ date_time_test.testEquivalentYears = function() { |
+ let dt = new core.DateTime.fromMillisecondsSinceEpoch(-31485600000, {isUtc: true}); |
+ expect$.Expect.equals(1969, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-63108000000, {isUtc: true}); |
+ expect$.Expect.equals(1968, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-94644000000, {isUtc: true}); |
+ expect$.Expect.equals(1967, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-126180000000, {isUtc: true}); |
+ expect$.Expect.equals(1966, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-157716000000, {isUtc: true}); |
+ expect$.Expect.equals(1965, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-2177402400000, {isUtc: true}); |
+ expect$.Expect.equals(1901, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-5333076000000, {isUtc: true}); |
+ expect$.Expect.equals(1801, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-8520285600000, {isUtc: true}); |
+ expect$.Expect.equals(1700, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-14831719200000, {isUtc: true}); |
+ expect$.Expect.equals(1500, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-59011408800000, {isUtc: true}); |
+ expect$.Expect.equals(100, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(14, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-62011408800000, {isUtc: true}); |
+ expect$.Expect.equals(4, dt.year); |
+ expect$.Expect.equals(12, dt.month); |
+ expect$.Expect.equals(8, dt.day); |
+ expect$.Expect.equals(8, dt.hour); |
+ expect$.Expect.equals(40, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-64011408800000, {isUtc: true}); |
+ expect$.Expect.equals(-59, dt.year); |
+ expect$.Expect.equals(7, dt.month); |
+ expect$.Expect.equals(24, dt.day); |
+ expect$.Expect.equals(5, dt.hour); |
+ expect$.Expect.equals(6, dt.minute); |
+ expect$.Expect.equals(40, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ let SECONDS_YEAR_2035 = 2051222400; |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 + 1, {isUtc: true}); |
+ expect$.Expect.equals(2035, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(0, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(1, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 - 1, {isUtc: true}); |
+ expect$.Expect.equals(2034, dt.year); |
+ expect$.Expect.equals(12, dt.month); |
+ expect$.Expect.equals(31, dt.day); |
+ expect$.Expect.equals(23, dt.hour); |
+ expect$.Expect.equals(59, dt.minute); |
+ expect$.Expect.equals(59, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.utc(2035, 1, 1, 0, 0, 0, 1); |
+ expect$.Expect.equals(SECONDS_YEAR_2035 * 1000 + 1, dt.millisecondsSinceEpoch); |
+ dt = new core.DateTime.utc(2034, 12, 31, 23, 59, 59, 999); |
+ expect$.Expect.equals(SECONDS_YEAR_2035 * 1000 - 1, dt.millisecondsSinceEpoch); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 + 1); |
+ expect$.Expect.equals(true, 2035 == dt.year && 1 == dt.month && 1 == dt.day || 2034 == dt.year && 12 == dt.month && 31 == dt.day); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(1, dt.millisecond); |
+ let dt2 = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond); |
+ expect$.Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 - 1); |
+ expect$.Expect.equals(true, 2035 == dt.year && 1 == dt.month && 1 == dt.day || 2034 == dt.year && 12 == dt.month && 31 == dt.day); |
+ expect$.Expect.equals(59, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt2 = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond); |
+ expect$.Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(2100000000 * 1000, {isUtc: true}); |
+ expect$.Expect.equals(2036, dt.year); |
+ expect$.Expect.equals(7, dt.month); |
+ expect$.Expect.equals(18, dt.day); |
+ expect$.Expect.equals(13, dt.hour); |
+ expect$.Expect.equals(20, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime(2036, 7, 18, 13, 20); |
+ expect$.Expect.equals(2036, dt.year); |
+ expect$.Expect.equals(7, dt.month); |
+ expect$.Expect.equals(18, dt.day); |
+ expect$.Expect.equals(13, dt.hour); |
+ expect$.Expect.equals(20, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ expect$.Expect.equals("2036-07-18 13:20:00.000", dt.toString()); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ dt = new core.DateTime.utc(2035, 1, 1, 0, 0, 0, 0, 1); |
+ expect$.Expect.equals(SECONDS_YEAR_2035 * 1000000 + 1, dt.microsecondsSinceEpoch); |
+ dt = new core.DateTime.utc(2034, 12, 31, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals(SECONDS_YEAR_2035 * 1000000 - 1, dt.microsecondsSinceEpoch); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(SECONDS_YEAR_2035 * 1000000 + 1); |
+ expect$.Expect.equals(true, 2035 == dt.year && 1 == dt.month && 1 == dt.day || 2034 == dt.year && 12 == dt.month && 31 == dt.day); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(1, dt.microsecond); |
+ dt2 = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond, dt.microsecond); |
+ expect$.Expect.equals(dt.microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(SECONDS_YEAR_2035 * 1000000 - 1); |
+ expect$.Expect.equals(true, 2035 == dt.year && 1 == dt.month && 1 == dt.day || 2034 == dt.year && 12 == dt.month && 31 == dt.day); |
+ expect$.Expect.equals(59, dt.second); |
+ expect$.Expect.equals(999, dt.millisecond); |
+ expect$.Expect.equals(999, dt.microsecond); |
+ dt2 = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond, dt.microsecond); |
+ expect$.Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(2100000000 * 1000000, {isUtc: true}); |
+ expect$.Expect.equals(2036, dt.year); |
+ expect$.Expect.equals(7, dt.month); |
+ expect$.Expect.equals(18, dt.day); |
+ expect$.Expect.equals(13, dt.hour); |
+ expect$.Expect.equals(20, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ }; |
+ dart.fn(date_time_test.testEquivalentYears, VoidTovoid()); |
+ date_time_test.testExtremes = function() { |
+ let dt = new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS, {isUtc: true}); |
+ expect$.Expect.equals(275760, dt.year); |
+ expect$.Expect.equals(9, dt.month); |
+ expect$.Expect.equals(13, dt.day); |
+ expect$.Expect.equals(0, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS, {isUtc: true}); |
+ expect$.Expect.equals(-271821, dt.year); |
+ expect$.Expect.equals(4, dt.month); |
+ expect$.Expect.equals(20, dt.day); |
+ expect$.Expect.equals(0, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS); |
+ dt = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); |
+ expect$.Expect.equals(date_time_test._MAX_MILLISECONDS, dt.millisecondsSinceEpoch); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS); |
+ dt = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); |
+ expect$.Expect.equals(-date_time_test._MAX_MILLISECONDS, dt.millisecondsSinceEpoch); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS + 1, {isUtc: true}), VoidToDateTime())); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS - 1, {isUtc: true}), VoidToDateTime())); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS + 1), VoidToDateTime())); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS - 1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS, {isUtc: true}); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS, {isUtc: true}); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1), VoidToDateTime())); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(date_time_test._MAX_MILLISECONDS * 1000); |
+ dt = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); |
+ expect$.Expect.equals(date_time_test._MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch); |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS * 1000); |
+ dt = new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); |
+ expect$.Expect.equals(-date_time_test._MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMicrosecondsSinceEpoch(date_time_test._MAX_MILLISECONDS * 1000 + 1, {isUtc: true}), VoidToDateTime())); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMicrosecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS * 1000 - 1, {isUtc: true}), VoidToDateTime())); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMicrosecondsSinceEpoch(date_time_test._MAX_MILLISECONDS * 1000 + 1), VoidToDateTime())); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.fromMicrosecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS * 1000 - 1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(date_time_test._MAX_MILLISECONDS, {isUtc: true}); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1), VoidToDateTime())); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-date_time_test._MAX_MILLISECONDS, {isUtc: true}); |
+ expect$.Expect.throws(dart.fn(() => new core.DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1), VoidToDateTime())); |
+ }; |
+ dart.fn(date_time_test.testExtremes, VoidTovoid()); |
+ date_time_test.testUTCGetters = function() { |
+ let dt = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000, {isUtc: true}); |
+ expect$.Expect.equals(2011, dt.year); |
+ expect$.Expect.equals(5, dt.month); |
+ expect$.Expect.equals(11, dt.day); |
+ expect$.Expect.equals(18, dt.hour); |
+ expect$.Expect.equals(58, dt.minute); |
+ expect$.Expect.equals(35, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ expect$.Expect.equals(true, dt.isUtc); |
+ expect$.Expect.equals(1305140315000, dt.millisecondsSinceEpoch); |
+ dt = new core.DateTime.fromMillisecondsSinceEpoch(-9999999, {isUtc: true}); |
+ expect$.Expect.equals(1969, dt.year); |
+ expect$.Expect.equals(12, dt.month); |
+ expect$.Expect.equals(31, dt.day); |
+ expect$.Expect.equals(21, dt.hour); |
+ expect$.Expect.equals(13, dt.minute); |
+ expect$.Expect.equals(20, dt.second); |
+ expect$.Expect.equals(1, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ dt = new core.DateTime.fromMicrosecondsSinceEpoch(-9999999999, {isUtc: true}); |
+ expect$.Expect.equals(1969, dt.year); |
+ expect$.Expect.equals(12, dt.month); |
+ expect$.Expect.equals(31, dt.day); |
+ expect$.Expect.equals(21, dt.hour); |
+ expect$.Expect.equals(13, dt.minute); |
+ expect$.Expect.equals(20, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(1, dt.microsecond); |
+ }; |
+ dart.fn(date_time_test.testUTCGetters, VoidTovoid()); |
+ date_time_test.testLocalGetters = function() { |
+ let dt1 = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000); |
+ let dt2 = new core.DateTime.utc(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, dt1.second, dt1.millisecond, dt1.microsecond); |
+ let zoneOffset = dt1.difference(dt2); |
+ expect$.Expect.equals(true, zoneOffset.inDays == 0); |
+ expect$.Expect.equals(true, dart.notNull(zoneOffset.inHours[dartx.abs]()) <= 12); |
+ expect$.Expect.equals(dt1.year, dt2.year); |
+ expect$.Expect.equals(dt1.month, dt2.month); |
+ expect$.Expect.equals(true, dart.notNull((dart.notNull(dt1.day) - dart.notNull(dt2.day))[dartx.abs]()) <= 1); |
+ expect$.Expect.equals(true, dart.notNull(dt1.hour) < 24); |
+ expect$.Expect.equals(true, dt1.minute == dt2.minute || (dart.notNull(dt1.minute) - dart.notNull(dt2.minute))[dartx.abs]() == 30 || (dart.notNull(dt1.minute) - dart.notNull(dt2.minute))[dartx.abs]() == 15); |
+ expect$.Expect.equals(dt1.second, dt2.second); |
+ expect$.Expect.equals(dt1.millisecond, dt2.millisecond); |
+ expect$.Expect.equals(dt1.microsecond, dt2.microsecond); |
+ }; |
+ dart.fn(date_time_test.testLocalGetters, VoidTovoid()); |
+ date_time_test.testConstructors = function() { |
+ let dt0 = new core.DateTime.utc(2011, 5, 11, 18, 58, 35, 0, 0); |
+ let dt0b = new core.DateTime.utc(2011, 5, 11, 18, 58, 35, 0, 0).toLocal(); |
+ expect$.Expect.equals(1305140315000, dt0.millisecondsSinceEpoch); |
+ let dt1 = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000); |
+ expect$.Expect.equals(dt1.millisecondsSinceEpoch, dt0.millisecondsSinceEpoch); |
+ expect$.Expect.equals(dt1.microsecondsSinceEpoch, dt0.microsecondsSinceEpoch); |
+ expect$.Expect.equals(false, dart.equals(dt1, dt0)); |
+ expect$.Expect.equals(true, dart.equals(dt1, dt0b)); |
+ let dt3 = new core.DateTime(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, dt1.second, dt1.millisecond, dt1.microsecond); |
+ expect$.Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); |
+ expect$.Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); |
+ expect$.Expect.equals(false, dart.equals(dt3, dt0)); |
+ expect$.Expect.equals(true, dart.equals(dt1, dt3)); |
+ dt3 = new core.DateTime(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, dt1.second, dt1.millisecond, dt1.microsecond); |
+ expect$.Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); |
+ expect$.Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); |
+ expect$.Expect.equals(true, dart.equals(dt1, dt3)); |
+ let dt2 = dt1.toLocal(); |
+ dt3 = new core.DateTime(2011, 5, dt1.day, dt1.hour, dt1.minute, 35, 0, 0); |
+ expect$.Expect.equals(dt2.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); |
+ expect$.Expect.equals(dt2.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); |
+ expect$.Expect.equals(true, dart.equals(dt2, dt3)); |
+ dt1 = new core.DateTime.fromMillisecondsSinceEpoch(-9999999, {isUtc: true}); |
+ dt3 = new core.DateTime.utc(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, dt1.second, dt1.millisecond); |
+ expect$.Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); |
+ expect$.Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); |
+ dt3 = new core.DateTime.utc(99, 1, 2, 10, 11, 12, 0); |
+ expect$.Expect.equals(99, dt3.year); |
+ expect$.Expect.equals(1, dt3.month); |
+ expect$.Expect.equals(2, dt3.day); |
+ expect$.Expect.equals(10, dt3.hour); |
+ expect$.Expect.equals(11, dt3.minute); |
+ expect$.Expect.equals(12, dt3.second); |
+ expect$.Expect.equals(0, dt3.millisecond); |
+ expect$.Expect.equals(0, dt3.microsecond); |
+ expect$.Expect.equals(true, dt3.isUtc); |
+ let dt4 = new core.DateTime(99, 1, 2); |
+ expect$.Expect.equals(99, dt4.year); |
+ expect$.Expect.equals(1, dt4.month); |
+ expect$.Expect.equals(2, dt4.day); |
+ expect$.Expect.equals(0, dt4.hour); |
+ expect$.Expect.equals(0, dt4.minute); |
+ expect$.Expect.equals(0, dt4.second); |
+ expect$.Expect.equals(0, dt4.millisecond); |
+ expect$.Expect.equals(0, dt4.microsecond); |
+ expect$.Expect.isFalse(dt4.isUtc); |
+ let dt5 = new core.DateTime.utc(99, 1, 2); |
+ expect$.Expect.equals(99, dt5.year); |
+ expect$.Expect.equals(1, dt5.month); |
+ expect$.Expect.equals(2, dt5.day); |
+ expect$.Expect.equals(0, dt5.hour); |
+ expect$.Expect.equals(0, dt5.minute); |
+ expect$.Expect.equals(0, dt5.second); |
+ expect$.Expect.equals(0, dt5.millisecond); |
+ expect$.Expect.equals(0, dt5.microsecond); |
+ expect$.Expect.isTrue(dt5.isUtc); |
+ let dt6 = new core.DateTime(2012, 2, 27, 13, 27, 0); |
+ expect$.Expect.equals(2012, dt6.year); |
+ expect$.Expect.equals(2, dt6.month); |
+ expect$.Expect.equals(27, dt6.day); |
+ expect$.Expect.equals(13, dt6.hour); |
+ expect$.Expect.equals(27, dt6.minute); |
+ expect$.Expect.equals(0, dt6.second); |
+ expect$.Expect.equals(0, dt6.millisecond); |
+ expect$.Expect.equals(0, dt6.microsecond); |
+ expect$.Expect.isFalse(dt6.isUtc); |
+ let dt7 = new core.DateTime.utc(2012, 2, 27, 13, 27, 0); |
+ expect$.Expect.equals(2012, dt7.year); |
+ expect$.Expect.equals(2, dt7.month); |
+ expect$.Expect.equals(27, dt7.day); |
+ expect$.Expect.equals(13, dt7.hour); |
+ expect$.Expect.equals(27, dt7.minute); |
+ expect$.Expect.equals(0, dt7.second); |
+ expect$.Expect.equals(0, dt7.millisecond); |
+ expect$.Expect.equals(0, dt7.microsecond); |
+ expect$.Expect.isTrue(dt7.isUtc); |
+ }; |
+ dart.fn(date_time_test.testConstructors, VoidTovoid()); |
+ date_time_test.testChangeTimeZone = function() { |
+ let dt1 = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000); |
+ let dt2 = dt1.toUtc(); |
+ expect$.Expect.equals(dt1.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
+ let dt3 = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000, {isUtc: true}); |
+ expect$.Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); |
+ expect$.Expect.equals(dt2.year, dt3.year); |
+ expect$.Expect.equals(dt2.month, dt3.month); |
+ expect$.Expect.equals(dt2.day, dt3.day); |
+ expect$.Expect.equals(dt2.hour, dt3.hour); |
+ expect$.Expect.equals(dt2.minute, dt3.minute); |
+ expect$.Expect.equals(dt2.second, dt3.second); |
+ expect$.Expect.equals(dt2.millisecond, dt3.millisecond); |
+ expect$.Expect.equals(dt2.microsecond, dt3.microsecond); |
+ let dt4 = dt3.toLocal(); |
+ expect$.Expect.equals(dt1.year, dt4.year); |
+ expect$.Expect.equals(dt1.month, dt4.month); |
+ expect$.Expect.equals(dt1.day, dt4.day); |
+ expect$.Expect.equals(dt1.hour, dt4.hour); |
+ expect$.Expect.equals(dt1.minute, dt4.minute); |
+ expect$.Expect.equals(dt1.second, dt4.second); |
+ expect$.Expect.equals(dt1.millisecond, dt4.millisecond); |
+ expect$.Expect.equals(dt1.microsecond, dt4.microsecond); |
+ }; |
+ dart.fn(date_time_test.testChangeTimeZone, VoidTovoid()); |
+ date_time_test.testSubAdd = function() { |
+ let dt1 = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000, {isUtc: true}); |
+ let dt2 = dt1.add(new core.Duration({milliseconds: 3 * core.Duration.MILLISECONDS_PER_SECOND + 5})); |
+ expect$.Expect.equals(dt1.year, dt2.year); |
+ expect$.Expect.equals(dt1.month, dt2.month); |
+ expect$.Expect.equals(dt1.day, dt2.day); |
+ expect$.Expect.equals(dt1.hour, dt2.hour); |
+ expect$.Expect.equals(dt1.minute, dt2.minute); |
+ expect$.Expect.equals(dart.notNull(dt1.second) + 3, dt2.second); |
+ expect$.Expect.equals(dart.notNull(dt1.millisecond) + 5, dt2.millisecond); |
+ expect$.Expect.equals(dt1.microsecond, dt2.microsecond); |
+ let dt3 = dt2.subtract(new core.Duration({milliseconds: 3 * core.Duration.MILLISECONDS_PER_SECOND + 5})); |
+ expect$.Expect.equals(true, dart.equals(dt1, dt3)); |
+ expect$.Expect.equals(false, dart.equals(dt1, dt2)); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ dt1 = new core.DateTime.fromMillisecondsSinceEpoch(1305140315000, {isUtc: true}); |
+ dt2 = dt1.add(new core.Duration({microseconds: 3 * core.Duration.MICROSECONDS_PER_SECOND + 5})); |
+ expect$.Expect.equals(dt1.year, dt2.year); |
+ expect$.Expect.equals(dt1.month, dt2.month); |
+ expect$.Expect.equals(dt1.day, dt2.day); |
+ expect$.Expect.equals(dt1.hour, dt2.hour); |
+ expect$.Expect.equals(dt1.minute, dt2.minute); |
+ expect$.Expect.equals(dart.notNull(dt1.second) + 3, dt2.second); |
+ expect$.Expect.equals(dt1.millisecond, dt2.millisecond); |
+ expect$.Expect.equals(dart.notNull(dt1.microsecond) + 5, dt2.microsecond); |
+ dt3 = dt2.subtract(new core.Duration({microseconds: 3 * core.Duration.MICROSECONDS_PER_SECOND + 5})); |
+ expect$.Expect.equals(true, dart.equals(dt1, dt3)); |
+ expect$.Expect.equals(false, dart.equals(dt1, dt2)); |
+ }; |
+ dart.fn(date_time_test.testSubAdd, VoidTovoid()); |
+ date_time_test.testUnderflowAndOverflow = function() { |
+ let microsecond = dart.test(date_time_test.supportsMicroseconds) ? 499 : 0; |
+ let dtBase = new core.DateTime(2012, 6, 20, 12, 30, 30, 500, microsecond); |
+ core.print(" >>> Millisecond+"); |
+ let dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, dtBase.minute, dtBase.second, 1000, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dart.notNull(dtBase.second) + 1, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Millisecond-"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, dtBase.minute, dtBase.second, -1000, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dart.notNull(dtBase.second) - 1, dt.second); |
+ expect$.Expect.equals(0, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Second+"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, dtBase.minute, 60, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dart.notNull(dtBase.minute) + 1, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Second-"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, dtBase.minute, -60, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dart.notNull(dtBase.minute) - 1, dt.minute); |
+ expect$.Expect.equals(0, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Minute+"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, 60, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dart.notNull(dtBase.hour) + 1, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Minute-"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, -60, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dart.notNull(dtBase.hour) - 1, dt.hour); |
+ expect$.Expect.equals(0, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Hour+"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, 24, dtBase.minute, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dart.notNull(dtBase.day) + 1, dt.day); |
+ expect$.Expect.equals(0, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Hour-"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, -24, dtBase.minute, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dart.notNull(dtBase.day) - 1, dt.day); |
+ expect$.Expect.equals(0, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Day+"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, 31, dtBase.hour, dtBase.minute, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dart.notNull(dtBase.month) + 1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Day-"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, -30, dtBase.hour, dtBase.minute, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dart.notNull(dtBase.month) - 1, dt.month); |
+ expect$.Expect.equals(1, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Month+"); |
+ dt = new core.DateTime(dtBase.year, 13, dtBase.day, dtBase.hour, dtBase.minute, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dart.notNull(dtBase.year) + 1, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Month-"); |
+ dt = new core.DateTime(dtBase.year, -11, dtBase.day, dtBase.hour, dtBase.minute, dtBase.second, dtBase.millisecond, dtBase.microsecond); |
+ expect$.Expect.equals(dart.notNull(dtBase.year) - 1, dt.year); |
+ expect$.Expect.equals(1, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dtBase.millisecond, dt.millisecond); |
+ expect$.Expect.equals(dtBase.microsecond, dt.microsecond); |
+ core.print(" >>> Flow+"); |
+ let dtBase1 = new core.DateTime(2012, 12, 31, 23, 59, 59, 999, 0); |
+ let dtTick = new core.DateTime(dtBase1.year, dtBase1.month, dtBase1.day, dtBase1.hour, dtBase1.minute, dtBase1.second, dart.notNull(dtBase1.millisecond) + 1, dtBase1.microsecond); |
+ expect$.Expect.equals(dart.notNull(dtBase1.year) + 1, dtTick.year); |
+ expect$.Expect.equals(1, dtTick.month); |
+ expect$.Expect.equals(1, dtTick.day); |
+ expect$.Expect.equals(0, dtTick.hour); |
+ expect$.Expect.equals(0, dtTick.minute); |
+ expect$.Expect.equals(0, dtTick.second); |
+ expect$.Expect.equals(0, dtTick.millisecond); |
+ expect$.Expect.equals(0, dtTick.microsecond); |
+ core.print(" >>> Flow-"); |
+ dtBase1 = new core.DateTime(2012, 1, 1, 0, 0, 0, 0); |
+ dtTick = new core.DateTime(dtBase1.year, dtBase1.month, dtBase1.day, dtBase1.hour, dtBase1.minute, dtBase1.second, dart.notNull(dtBase1.millisecond) - 1, dtBase1.microsecond); |
+ expect$.Expect.equals(dart.notNull(dtBase1.year) - 1, dtTick.year); |
+ expect$.Expect.equals(12, dtTick.month); |
+ expect$.Expect.equals(31, dtTick.day); |
+ expect$.Expect.equals(23, dtTick.hour); |
+ expect$.Expect.equals(59, dtTick.minute); |
+ expect$.Expect.equals(59, dtTick.second); |
+ expect$.Expect.equals(999, dtTick.millisecond); |
+ expect$.Expect.equals(0, dtTick.microsecond); |
+ core.print(" >>> extra underflow"); |
+ dtTick = new core.DateTime(dtBase1.year, dtBase1.month, dtBase1.day, -17520, dtBase1.minute, dtBase1.second, dtBase1.millisecond, dtBase1.microsecond); |
+ expect$.Expect.equals(dart.notNull(dtBase1.year) - 2, dtTick.year); |
+ expect$.Expect.equals(dtBase1.month, dtTick.month); |
+ expect$.Expect.equals(dtBase1.day, dtTick.day); |
+ expect$.Expect.equals(dtBase1.hour, dtTick.hour); |
+ expect$.Expect.equals(dtBase1.minute, dtTick.minute); |
+ expect$.Expect.equals(dtBase1.second, dtTick.second); |
+ expect$.Expect.equals(dtBase1.millisecond, dtTick.millisecond); |
+ expect$.Expect.equals(dtBase1.microsecond, dtTick.microsecond); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ core.print(" >>> Microsecond+"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, dtBase.minute, dtBase.second, dtBase.millisecond, 1000); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dart.notNull(dtBase.millisecond) + 1, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ core.print(" >>> Microsecond-"); |
+ dt = new core.DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, dtBase.minute, dtBase.second, dtBase.millisecond, -1000); |
+ expect$.Expect.equals(dtBase.year, dt.year); |
+ expect$.Expect.equals(dtBase.month, dt.month); |
+ expect$.Expect.equals(dtBase.day, dt.day); |
+ expect$.Expect.equals(dtBase.hour, dt.hour); |
+ expect$.Expect.equals(dtBase.minute, dt.minute); |
+ expect$.Expect.equals(dtBase.second, dt.second); |
+ expect$.Expect.equals(dart.notNull(dtBase.millisecond) - 1, dt.millisecond); |
+ expect$.Expect.equals(0, dt.microsecond); |
+ core.print(" >>> Flow+ 2"); |
+ dtBase1 = new core.DateTime(2012, 12, 31, 23, 59, 59, 999, 999); |
+ dtTick = new core.DateTime(dtBase1.year, dtBase1.month, dtBase1.day, dtBase1.hour, dtBase1.minute, dtBase1.second, dtBase1.millisecond, dart.notNull(dtBase1.microsecond) + 1); |
+ expect$.Expect.equals(dart.notNull(dtBase1.year) + 1, dtTick.year); |
+ expect$.Expect.equals(1, dtTick.month); |
+ expect$.Expect.equals(1, dtTick.day); |
+ expect$.Expect.equals(0, dtTick.hour); |
+ expect$.Expect.equals(0, dtTick.minute); |
+ expect$.Expect.equals(0, dtTick.second); |
+ expect$.Expect.equals(0, dtTick.millisecond); |
+ expect$.Expect.equals(0, dtTick.microsecond); |
+ core.print(" >>> Flow- 2"); |
+ dtBase1 = new core.DateTime(2012, 1, 1, 0, 0, 0, 0, 0); |
+ dtTick = new core.DateTime(dtBase1.year, dtBase1.month, dtBase1.day, dtBase1.hour, dtBase1.minute, dtBase1.second, dtBase1.millisecond, dart.notNull(dtBase1.microsecond) - 1); |
+ expect$.Expect.equals(dart.notNull(dtBase1.year) - 1, dtTick.year); |
+ expect$.Expect.equals(12, dtTick.month); |
+ expect$.Expect.equals(31, dtTick.day); |
+ expect$.Expect.equals(23, dtTick.hour); |
+ expect$.Expect.equals(59, dtTick.minute); |
+ expect$.Expect.equals(59, dtTick.second); |
+ expect$.Expect.equals(999, dtTick.millisecond); |
+ expect$.Expect.equals(999, dtTick.microsecond); |
+ }; |
+ dart.fn(date_time_test.testUnderflowAndOverflow, VoidTovoid()); |
+ date_time_test.testDateStrings = function() { |
+ let dt1 = core.DateTime.parse("2011-05-11 18:58:35Z"); |
+ expect$.Expect.equals(1305140315000, dt1.millisecondsSinceEpoch); |
+ expect$.Expect.isTrue(dt1.isUtc); |
+ dt1 = core.DateTime.parse("20110511 18:58:35z"); |
+ expect$.Expect.equals(1305140315000, dt1.millisecondsSinceEpoch); |
+ expect$.Expect.isTrue(dt1.isUtc); |
+ dt1 = core.DateTime.parse("+20110511 18:58:35z"); |
+ expect$.Expect.equals(1305140315000, dt1.millisecondsSinceEpoch); |
+ expect$.Expect.isTrue(dt1.isUtc); |
+ let str = dart.toString(dt1); |
+ let dt2 = core.DateTime.parse(str); |
+ expect$.Expect.equals(true, dart.equals(dt1, dt2)); |
+ let dt3 = dt1.toUtc(); |
+ str = dart.toString(dt3); |
+ expect$.Expect.equals("2011-05-11 18:58:35.000Z", str); |
+ let dt4 = core.DateTime.parse("-1234-01-01 00:00:00Z"); |
+ expect$.Expect.equals(-1234, dt4.year); |
+ expect$.Expect.equals(1, dt4.month); |
+ expect$.Expect.equals(1, dt4.day); |
+ expect$.Expect.equals(0, dt4.hour); |
+ expect$.Expect.equals(0, dt4.minute); |
+ expect$.Expect.equals(0, dt4.second); |
+ expect$.Expect.equals(0, dt4.millisecond); |
+ expect$.Expect.equals(0, dt4.microsecond); |
+ expect$.Expect.isTrue(dt4.isUtc); |
+ let dt5 = core.DateTime.parse("0099-01-02"); |
+ expect$.Expect.equals(99, dt5.year); |
+ expect$.Expect.equals(1, dt5.month); |
+ expect$.Expect.equals(2, dt5.day); |
+ expect$.Expect.equals(0, dt5.hour); |
+ expect$.Expect.equals(0, dt5.minute); |
+ expect$.Expect.equals(0, dt5.second); |
+ expect$.Expect.equals(0, dt5.millisecond); |
+ expect$.Expect.equals(0, dt5.microsecond); |
+ expect$.Expect.isFalse(dt5.isUtc); |
+ let dt6 = core.DateTime.parse("2012-01-01 00:00:10.012"); |
+ expect$.Expect.equals(12, dt6.millisecond); |
+ expect$.Expect.equals(0, dt6.microsecond); |
+ dt6 = core.DateTime.parse("2012-01-01 00:00:10.003"); |
+ expect$.Expect.equals(3, dt6.millisecond); |
+ expect$.Expect.equals(0, dt6.microsecond); |
+ dt6 = core.DateTime.parse("2012-01-01 00:00:10.5"); |
+ expect$.Expect.equals(500, dt6.millisecond); |
+ expect$.Expect.equals(0, dt6.microsecond); |
+ dt6 = core.DateTime.parse("2012-01-01 00:00:10.003Z"); |
+ expect$.Expect.equals(3, dt6.millisecond); |
+ expect$.Expect.equals(0, dt6.microsecond); |
+ dt6 = core.DateTime.parse("2012-01-01 00:00:10.5z"); |
+ expect$.Expect.equals(500, dt6.millisecond); |
+ expect$.Expect.equals(0, dt6.microsecond); |
+ let dt7 = core.DateTime.parse("2011-05-11T18:58:35Z"); |
+ expect$.Expect.equals(1305140315000, dt7.millisecondsSinceEpoch); |
+ let dt8 = core.DateTime.parse("-1234-01-01T00:00:00Z"); |
+ expect$.Expect.equals(-1234, dt8.year); |
+ expect$.Expect.equals(1, dt8.month); |
+ expect$.Expect.equals(1, dt8.day); |
+ expect$.Expect.equals(0, dt8.hour); |
+ expect$.Expect.equals(0, dt8.minute); |
+ expect$.Expect.equals(0, dt8.second); |
+ expect$.Expect.equals(0, dt8.millisecond); |
+ expect$.Expect.equals(0, dt8.microsecond); |
+ expect$.Expect.isTrue(dt8.isUtc); |
+ let dt9 = core.DateTime.parse("-1234-01-01T00:00:00"); |
+ expect$.Expect.equals(-1234, dt9.year); |
+ expect$.Expect.equals(1, dt9.month); |
+ expect$.Expect.equals(1, dt9.day); |
+ expect$.Expect.equals(0, dt9.hour); |
+ expect$.Expect.equals(0, dt9.minute); |
+ expect$.Expect.equals(0, dt9.second); |
+ expect$.Expect.equals(0, dt9.millisecond); |
+ expect$.Expect.equals(0, dt9.microsecond); |
+ expect$.Expect.isFalse(dt9.isUtc); |
+ let dt10 = core.DateTime.parse("-12340101"); |
+ expect$.Expect.equals(-1234, dt10.year); |
+ expect$.Expect.equals(1, dt10.month); |
+ expect$.Expect.equals(1, dt10.day); |
+ expect$.Expect.equals(0, dt10.hour); |
+ expect$.Expect.equals(0, dt10.minute); |
+ expect$.Expect.equals(0, dt10.second); |
+ expect$.Expect.equals(0, dt10.millisecond); |
+ expect$.Expect.equals(0, dt10.microsecond); |
+ expect$.Expect.isFalse(dt10.isUtc); |
+ dt1 = core.DateTime.parse("2012-02-27 13:27:00"); |
+ expect$.Expect.equals(2012, dt1.year); |
+ expect$.Expect.equals(2, dt1.month); |
+ expect$.Expect.equals(27, dt1.day); |
+ expect$.Expect.equals(13, dt1.hour); |
+ expect$.Expect.equals(27, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(false, dt1.isUtc); |
+ dt1 = core.DateTime.parse("2012-02-27 13:27:00.423z"); |
+ expect$.Expect.equals(2012, dt1.year); |
+ expect$.Expect.equals(2, dt1.month); |
+ expect$.Expect.equals(27, dt1.day); |
+ expect$.Expect.equals(13, dt1.hour); |
+ expect$.Expect.equals(27, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(423, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("20120227 13:27:00"); |
+ expect$.Expect.equals(2012, dt1.year); |
+ expect$.Expect.equals(2, dt1.month); |
+ expect$.Expect.equals(27, dt1.day); |
+ expect$.Expect.equals(13, dt1.hour); |
+ expect$.Expect.equals(27, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(false, dt1.isUtc); |
+ dt1 = core.DateTime.parse("20120227T132700"); |
+ expect$.Expect.equals(2012, dt1.year); |
+ expect$.Expect.equals(2, dt1.month); |
+ expect$.Expect.equals(27, dt1.day); |
+ expect$.Expect.equals(13, dt1.hour); |
+ expect$.Expect.equals(27, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(false, dt1.isUtc); |
+ dt1 = core.DateTime.parse("20120227"); |
+ expect$.Expect.equals(2012, dt1.year); |
+ expect$.Expect.equals(2, dt1.month); |
+ expect$.Expect.equals(27, dt1.day); |
+ expect$.Expect.equals(0, dt1.hour); |
+ expect$.Expect.equals(0, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(false, dt1.isUtc); |
+ dt1 = core.DateTime.parse("2012-02-27T14Z"); |
+ expect$.Expect.equals(2012, dt1.year); |
+ expect$.Expect.equals(2, dt1.month); |
+ expect$.Expect.equals(27, dt1.day); |
+ expect$.Expect.equals(14, dt1.hour); |
+ expect$.Expect.equals(0, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("-123450101 00:00:00 Z"); |
+ expect$.Expect.equals(-12345, dt1.year); |
+ expect$.Expect.equals(1, dt1.month); |
+ expect$.Expect.equals(1, dt1.day); |
+ expect$.Expect.equals(0, dt1.hour); |
+ expect$.Expect.equals(0, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("1999-01-02 23:59:59.99951"); |
+ if (dart.test(date_time_test.supportsMicroseconds)) { |
+ expect$.Expect.equals(1999, dt1.year); |
+ expect$.Expect.equals(1, dt1.month); |
+ expect$.Expect.equals(2, dt1.day); |
+ expect$.Expect.equals(23, dt1.hour); |
+ expect$.Expect.equals(59, dt1.minute); |
+ expect$.Expect.equals(59, dt1.second); |
+ expect$.Expect.equals(999, dt1.millisecond); |
+ expect$.Expect.equals(510, dt1.microsecond); |
+ } else { |
+ expect$.Expect.equals(1999, dt1.year); |
+ expect$.Expect.equals(1, dt1.month); |
+ expect$.Expect.equals(3, dt1.day); |
+ expect$.Expect.equals(0, dt1.hour); |
+ expect$.Expect.equals(0, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ } |
+ expect$.Expect.equals(false, dt1.isUtc); |
+ dt1 = core.DateTime.parse("1999-01-02 23:58:59.99951Z"); |
+ if (dart.test(date_time_test.supportsMicroseconds)) { |
+ expect$.Expect.equals(1999, dt1.year); |
+ expect$.Expect.equals(1, dt1.month); |
+ expect$.Expect.equals(2, dt1.day); |
+ expect$.Expect.equals(23, dt1.hour); |
+ expect$.Expect.equals(58, dt1.minute); |
+ expect$.Expect.equals(59, dt1.second); |
+ expect$.Expect.equals(999, dt1.millisecond); |
+ expect$.Expect.equals(510, dt1.microsecond); |
+ } else { |
+ expect$.Expect.equals(1999, dt1.year); |
+ expect$.Expect.equals(1, dt1.month); |
+ expect$.Expect.equals(2, dt1.day); |
+ expect$.Expect.equals(23, dt1.hour); |
+ expect$.Expect.equals(59, dt1.minute); |
+ expect$.Expect.equals(0, dt1.second); |
+ expect$.Expect.equals(0, dt1.millisecond); |
+ expect$.Expect.equals(0, dt1.microsecond); |
+ } |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009Z"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(9, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009-00"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(9, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009-0000"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(9, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009-02"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(11, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009+0200"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(7, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009+1200"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(8, dt1.day); |
+ expect$.Expect.equals(21, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009-1200"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(21, dt1.hour); |
+ expect$.Expect.equals(9, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009-0230"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(9, dt1.day); |
+ expect$.Expect.equals(11, dt1.hour); |
+ expect$.Expect.equals(39, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ dt1 = core.DateTime.parse("0009-09-09 09:09:09.009-2134"); |
+ expect$.Expect.equals(9, dt1.year); |
+ expect$.Expect.equals(9, dt1.month); |
+ expect$.Expect.equals(10, dt1.day); |
+ expect$.Expect.equals(6, dt1.hour); |
+ expect$.Expect.equals(43, dt1.minute); |
+ expect$.Expect.equals(9, dt1.second); |
+ expect$.Expect.equals(9, dt1.millisecond); |
+ expect$.Expect.equals(true, dt1.isUtc); |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse("bad"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ let bad_year = 1970 + (date_time_test._MAX_MILLISECONDS / (1000 * 60 * 60 * 24 * 365.2425))[dartx.truncate]() + 1; |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse(dart.notNull(dart.toString(bad_year)) + "-01-01"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ dt1 = core.DateTime.parse("275760-09-13T00:00:00.000Z"); |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse("275760-09-14T00:00:00.000Z"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse("275760-09-13T00:00:00.001Z"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ if (dart.test(date_time_test.supportsMicroseconds)) { |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse("275760-09-13T00:00:00.000001Z"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ } else { |
+ dt1 = core.DateTime.parse("275760-09-13T00:00:00.000001Z"); |
+ } |
+ dt1 = core.DateTime.parse("-271821-04-20T00:00:00.000Z"); |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse("-271821-04-19T23:59:59.999Z"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ if (dart.test(date_time_test.supportsMicroseconds)) { |
+ expect$.Expect.throws(dart.fn(() => core.DateTime.parse("-271821-04-19T23:59:59.999999Z"), VoidToDateTime()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
+ } |
+ }; |
+ dart.fn(date_time_test.testDateStrings, VoidTovoid()); |
+ date_time_test.testWeekday = function() { |
+ let d = new core.DateTime(2011, 10, 6, 0, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.THURSDAY, d.weekday); |
+ d = new core.DateTime.utc(2011, 10, 6, 0, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.THURSDAY, d.weekday); |
+ d = new core.DateTime(2011, 10, 5, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.WEDNESDAY, d.weekday); |
+ d = new core.DateTime.utc(2011, 10, 5, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.WEDNESDAY, d.weekday); |
+ d = new core.DateTime(1970, 1, 1, 0, 0, 0, 1); |
+ expect$.Expect.equals(core.DateTime.THURSDAY, d.weekday); |
+ d = new core.DateTime.utc(1970, 1, 1, 0, 0, 0, 1); |
+ expect$.Expect.equals(core.DateTime.THURSDAY, d.weekday); |
+ d = new core.DateTime.utc(1969, 12, 31, 23, 59, 59, 999); |
+ expect$.Expect.equals(core.DateTime.WEDNESDAY, d.weekday); |
+ d = new core.DateTime(1969, 12, 31, 23, 59, 59, 999); |
+ expect$.Expect.equals(core.DateTime.WEDNESDAY, d.weekday); |
+ d = new core.DateTime(2011, 10, 4, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.TUESDAY, d.weekday); |
+ d = new core.DateTime(2011, 10, 3, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.MONDAY, d.weekday); |
+ d = new core.DateTime(2011, 10, 2, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.SUNDAY, d.weekday); |
+ d = new core.DateTime(2011, 10, 1, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.SATURDAY, d.weekday); |
+ d = new core.DateTime(2011, 9, 30, 23, 45, 37, 0); |
+ expect$.Expect.equals(core.DateTime.FRIDAY, d.weekday); |
+ }; |
+ dart.fn(date_time_test.testWeekday, VoidTovoid()); |
+ date_time_test.testToStrings = function() { |
+ function test(date, time) { |
+ { |
+ let source1 = dart.str`${date} ${time}Z`; |
+ let source2 = dart.str`${date}T${time}Z`; |
+ let utcTime1 = core.DateTime.parse(source1); |
+ let utcTime2 = core.DateTime.parse(source1); |
+ expect$.Expect.isTrue(utcTime1.isUtc); |
+ expect$.Expect.equals(utcTime1, utcTime2); |
+ expect$.Expect.equals(source1, dart.toString(utcTime1)); |
+ expect$.Expect.equals(source2, utcTime1.toIso8601String()); |
+ } |
+ { |
+ let source1 = dart.str`${date} ${time}`; |
+ let source2 = dart.str`${date}T${time}`; |
+ let utcTime1 = core.DateTime.parse(source1); |
+ let utcTime2 = core.DateTime.parse(source1); |
+ expect$.Expect.isFalse(utcTime1.isUtc); |
+ expect$.Expect.equals(utcTime1, utcTime2); |
+ expect$.Expect.equals(source1, dart.toString(utcTime1)); |
+ expect$.Expect.equals(source2, utcTime1.toIso8601String()); |
+ } |
+ } |
+ dart.fn(test, dynamicAnddynamicTovoid()); |
+ test("2000-01-01", "12:00:00.000"); |
+ test("-2000-01-01", "12:00:00.000"); |
+ test("1970-01-01", "00:00:00.000"); |
+ test("1969-12-31", "23:59:59.999"); |
+ test("1969-09-09", "00:09:09.009"); |
+ if (dart.test(date_time_test.supportsMicroseconds)) { |
+ test("2000-01-01", "12:00:00.000001"); |
+ test("-2000-01-01", "12:00:00.000001"); |
+ test("1970-01-01", "00:00:00.000001"); |
+ test("1969-12-31", "23:59:59.999999"); |
+ test("1969-09-09", "00:09:09.009999"); |
+ } |
+ }; |
+ dart.fn(date_time_test.testToStrings, VoidTovoid()); |
+ date_time_test.testIsoString = function() { |
+ let d = new core.DateTime(9999, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("9999-01-01T23:59:59.999", d.toIso8601String()); |
+ d = new core.DateTime(-9999, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("-9999-01-01T23:59:59.999", d.toIso8601String()); |
+ d = new core.DateTime.utc(9999, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("9999-01-01T23:59:59.999Z", d.toIso8601String()); |
+ d = new core.DateTime.utc(-9999, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("-9999-01-01T23:59:59.999Z", d.toIso8601String()); |
+ d = new core.DateTime(10000, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("+010000-01-01T23:59:59.999", d.toIso8601String()); |
+ d = new core.DateTime(-10000, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("-010000-01-01T23:59:59.999", d.toIso8601String()); |
+ d = new core.DateTime.utc(10000, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("+010000-01-01T23:59:59.999Z", d.toIso8601String()); |
+ d = new core.DateTime.utc(-10000, 1, 1, 23, 59, 59, 999); |
+ expect$.Expect.equals("-010000-01-01T23:59:59.999Z", d.toIso8601String()); |
+ if (!dart.test(date_time_test.supportsMicroseconds)) return; |
+ d = new core.DateTime(9999, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("9999-01-01T23:59:59.999999", d.toIso8601String()); |
+ d = new core.DateTime(-9999, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("-9999-01-01T23:59:59.999999", d.toIso8601String()); |
+ d = new core.DateTime.utc(9999, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("9999-01-01T23:59:59.999999Z", d.toIso8601String()); |
+ d = new core.DateTime.utc(-9999, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("-9999-01-01T23:59:59.999999Z", d.toIso8601String()); |
+ d = new core.DateTime(10000, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("+010000-01-01T23:59:59.999999", d.toIso8601String()); |
+ d = new core.DateTime(-10000, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("-010000-01-01T23:59:59.999999", d.toIso8601String()); |
+ d = new core.DateTime.utc(10000, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("+010000-01-01T23:59:59.999999Z", d.toIso8601String()); |
+ d = new core.DateTime.utc(-10000, 1, 1, 23, 59, 59, 999, 999); |
+ expect$.Expect.equals("-010000-01-01T23:59:59.999999Z", d.toIso8601String()); |
+ d = new core.DateTime(9999, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("9999-01-01T23:49:59.989979", d.toIso8601String()); |
+ d = new core.DateTime(-9999, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("-9999-01-01T23:49:59.989979", d.toIso8601String()); |
+ d = new core.DateTime.utc(9999, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("9999-01-01T23:49:59.989979Z", d.toIso8601String()); |
+ d = new core.DateTime.utc(-9999, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("-9999-01-01T23:49:59.989979Z", d.toIso8601String()); |
+ d = new core.DateTime(10000, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("+010000-01-01T23:49:59.989979", d.toIso8601String()); |
+ d = new core.DateTime(-10000, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("-010000-01-01T23:49:59.989979", d.toIso8601String()); |
+ d = new core.DateTime.utc(10000, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("+010000-01-01T23:49:59.989979Z", d.toIso8601String()); |
+ d = new core.DateTime.utc(-10000, 1, 1, 23, 49, 59, 989, 979); |
+ expect$.Expect.equals("-010000-01-01T23:49:59.989979Z", d.toIso8601String()); |
+ }; |
+ dart.fn(date_time_test.testIsoString, VoidTovoid()); |
+ date_time_test.main = function() { |
+ date_time_test.testNow(); |
+ date_time_test.testMillisecondsSinceEpoch(); |
+ date_time_test.testMicrosecondsSinceEpoch(); |
+ date_time_test.testConstructors(); |
+ date_time_test.testUTCGetters(); |
+ date_time_test.testLocalGetters(); |
+ date_time_test.testChangeTimeZone(); |
+ date_time_test.testSubAdd(); |
+ date_time_test.testUnderflowAndOverflow(); |
+ date_time_test.testDateStrings(); |
+ date_time_test.testEquivalentYears(); |
+ date_time_test.testExtremes(); |
+ date_time_test.testFarAwayDates(); |
+ date_time_test.testWeekday(); |
+ date_time_test.testToStrings(); |
+ date_time_test.testIsoString(); |
+ }; |
+ dart.fn(date_time_test.main, VoidTovoid()); |
+ // Exports: |
+ exports.date_time_test = date_time_test; |
+}); |