Remove Date class and remove .time from DateTime.
Review URL: https://chromereviews.googleplex.com/3508024 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@103 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -12,7 +12,7 @@ class DateTimeUtils {
|
||||
|
||||
static final YESTERDAY = 'Yesterday';
|
||||
|
||||
static final MS_IN_WEEK = Date.DAYS_IN_WEEK * Time.MS_PER_DAY;
|
||||
static final MS_IN_WEEK = DateTime.DAYS_IN_WEEK * Time.MS_PER_DAY;
|
||||
|
||||
// TODO(jmesserly): workaround for missing DateTime.fromDate in Dartium
|
||||
// Remove this once that is implemented. See b/5055106
|
||||
@@ -118,9 +118,15 @@ class DateTimeUtils {
|
||||
* - otherwise, show just the date
|
||||
*/
|
||||
static String toRecentTimeString(DateTime then) {
|
||||
bool datesAreEqual(DateTime d1, DateTime d2) {
|
||||
return (d1.year == d2.year) && (d1.month == d2.month) &&
|
||||
(d1.day == d2.day);
|
||||
}
|
||||
|
||||
final now = new DateTime.now();
|
||||
if (then.date == now.date) {
|
||||
return toHourMinutesString(then.time);
|
||||
if (datesAreEqual(then, now)) {
|
||||
return toHourMinutesString(new Time(
|
||||
0, then.hours, then.minutes, then.seconds, then.milliseconds));
|
||||
}
|
||||
|
||||
final today = new DateTime(now.year, now.month, now.day, 0, 0, 0, 0);
|
||||
@@ -131,7 +137,13 @@ class DateTimeUtils {
|
||||
return WEEKDAYS[getWeekday(then)];
|
||||
} else {
|
||||
// TODO(jmesserly): locale specific date format
|
||||
return then.date.toString();
|
||||
String twoDigits(int n) {
|
||||
if (n >= 10) return "${n}";
|
||||
return "0${n}";
|
||||
}
|
||||
String twoDigitMonth = twoDigits(then.month);
|
||||
String twoDigitDay = twoDigits(then.day);
|
||||
return "${then.year}-${twoDigitMonth}-${twoDigitDay}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +154,7 @@ class DateTimeUtils {
|
||||
int msSince1970 = dateTime.difference(unixTimeStart).duration;
|
||||
int daysSince1970 = msSince1970 ~/ Time.MS_PER_DAY;
|
||||
// 1970-1-1 was Thursday
|
||||
return ((daysSince1970 + Date.THU) % Date.DAYS_IN_WEEK);
|
||||
return ((daysSince1970 + DateTime.THU) % DateTime.DAYS_IN_WEEK);
|
||||
}
|
||||
|
||||
/** Formats a time in H:MM A format */
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#source("src/bool.dart");
|
||||
#source("src/collection.dart");
|
||||
#source("src/comparable.dart");
|
||||
#source("src/date.dart");
|
||||
#source("src/date_time.dart");
|
||||
#source("src/double.dart");
|
||||
#source("src/exceptions.dart");
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#source("implementation/time_zone_implementation.dart");
|
||||
#source("implementation/type_token.dart");
|
||||
#source("src/implementation/array.dart");
|
||||
#source("src/implementation/date_implementation.dart");
|
||||
#source("src/implementation/dual_pivot_quicksort.dart");
|
||||
#source("src/implementation/exceptions.dart");
|
||||
#source("src/implementation/hash_map_set.dart");
|
||||
|
||||
@@ -33,23 +33,6 @@ class DateTimeImplementation implements DateTime {
|
||||
timeZone.isUtc) {
|
||||
}
|
||||
|
||||
factory DateTimeImplementation.fromDateAndTime(
|
||||
Date date,
|
||||
Time time,
|
||||
TimeZoneImplementation timeZone) {
|
||||
if (timeZone === null) {
|
||||
timeZone = new TimeZoneImplementation.local();
|
||||
}
|
||||
return new DateTimeImplementation.withTimeZone(date.year,
|
||||
date.month,
|
||||
date.day + time.days,
|
||||
time.hours,
|
||||
time.minutes,
|
||||
time.seconds,
|
||||
time.milliseconds,
|
||||
timeZone);
|
||||
}
|
||||
|
||||
DateTimeImplementation.now()
|
||||
: timeZone = new TimeZone.local(),
|
||||
value = _now() {
|
||||
@@ -78,14 +61,6 @@ class DateTimeImplementation implements DateTime {
|
||||
return new DateTime.fromEpoch(value, targetTimeZone);
|
||||
}
|
||||
|
||||
Date get date() {
|
||||
return new DateImplementation(year, month, day);
|
||||
}
|
||||
|
||||
Time get time() {
|
||||
return new TimeImplementation(0, hours, minutes, seconds, milliseconds);
|
||||
}
|
||||
|
||||
int get year() {
|
||||
return _getYear(value, isUtc());
|
||||
}
|
||||
@@ -127,12 +102,26 @@ class DateTimeImplementation implements DateTime {
|
||||
}
|
||||
|
||||
String toString() {
|
||||
String dateString = date.toString();
|
||||
String timeString = time.toString();
|
||||
String threeDigits(int n) {
|
||||
if (n >= 100) return "${n}";
|
||||
if (n > 10) return "0${n}";
|
||||
return "00${n}";
|
||||
}
|
||||
String twoDigits(int n) {
|
||||
if (n >= 10) return "${n}";
|
||||
return "0${n}";
|
||||
}
|
||||
|
||||
String m = twoDigits(month);
|
||||
String d = twoDigits(day);
|
||||
String h = twoDigits(hours);
|
||||
String min = twoDigits(minutes);
|
||||
String sec = twoDigits(seconds);
|
||||
String ms = threeDigits(milliseconds);
|
||||
if (timeZone.isUtc) {
|
||||
return "${dateString} ${timeString}Z";
|
||||
return "$year-$m-$d $h:$min:$sec.${ms}Z";
|
||||
} else {
|
||||
return "${dateString} ${timeString}";
|
||||
return "$year-$m-$d $h:$min:$sec.$ms";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
'bool.dart',
|
||||
'collection.dart',
|
||||
'comparable.dart',
|
||||
'date.dart',
|
||||
'date_time.dart',
|
||||
'double.dart',
|
||||
'exceptions.dart',
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Dart core library.
|
||||
|
||||
interface Date extends Comparable factory DateImplementation {
|
||||
/**
|
||||
* Creates a [Date] object for the given [year], [month] and [day].
|
||||
* No checks are performed on the input values.
|
||||
*/
|
||||
const Date(int year, int month, int day);
|
||||
|
||||
/**
|
||||
* Returns the year of the date.
|
||||
*/
|
||||
int get year();
|
||||
/**
|
||||
* Returns the month of the date [JAN..DEC].
|
||||
*/
|
||||
int get month();
|
||||
/**
|
||||
* Returns the day of the date [1..31].
|
||||
*/
|
||||
int get day();
|
||||
|
||||
/**
|
||||
* Returns the week day [MON..SUN].
|
||||
*
|
||||
* If the date is invalid throws an exception.
|
||||
* TODO(floitsch): what exception?
|
||||
*/
|
||||
int get weekday();
|
||||
|
||||
// Constants.
|
||||
|
||||
// Weekday constants that are returned by [weekday] method:
|
||||
static final int MON = 0;
|
||||
static final int TUE = 1;
|
||||
static final int WED = 2;
|
||||
static final int THU = 3;
|
||||
static final int FRI = 4;
|
||||
static final int SAT = 5;
|
||||
static final int SUN = 6;
|
||||
static final int DAYS_IN_WEEK = 7;
|
||||
|
||||
// Month constants that are returned by the [month] getter.
|
||||
static final int JAN = 1;
|
||||
static final int FEB = 2;
|
||||
static final int MAR = 3;
|
||||
static final int APR = 4;
|
||||
static final int MAY = 5;
|
||||
static final int JUN = 6;
|
||||
static final int JUL = 7;
|
||||
static final int AUG = 8;
|
||||
static final int SEP = 9;
|
||||
static final int OCT = 10;
|
||||
static final int NOV = 11;
|
||||
static final int DEC = 12;
|
||||
}
|
||||
+25
-18
@@ -8,6 +8,29 @@
|
||||
* DateTime is the public interface to a point in time.
|
||||
*/
|
||||
interface DateTime extends Comparable factory DateTimeImplementation {
|
||||
// Weekday constants that are returned by [weekday] method:
|
||||
static final int MON = 0;
|
||||
static final int TUE = 1;
|
||||
static final int WED = 2;
|
||||
static final int THU = 3;
|
||||
static final int FRI = 4;
|
||||
static final int SAT = 5;
|
||||
static final int SUN = 6;
|
||||
static final int DAYS_IN_WEEK = 7;
|
||||
|
||||
// Month constants that are returned by the [month] getter.
|
||||
static final int JAN = 1;
|
||||
static final int FEB = 2;
|
||||
static final int MAR = 3;
|
||||
static final int APR = 4;
|
||||
static final int MAY = 5;
|
||||
static final int JUN = 6;
|
||||
static final int JUL = 7;
|
||||
static final int AUG = 8;
|
||||
static final int SEP = 9;
|
||||
static final int OCT = 10;
|
||||
static final int NOV = 11;
|
||||
static final int DEC = 12;
|
||||
|
||||
/**
|
||||
* Constructs a [DateTime] instance based on the individual parts, in the
|
||||
@@ -34,12 +57,6 @@ interface DateTime extends Comparable factory DateTimeImplementation {
|
||||
int milliseconds,
|
||||
TimeZone timeZone);
|
||||
|
||||
/**
|
||||
* Constructs a [DateTime] instance based on the individual parts.
|
||||
* If [timeZone] is [:null:], then the local zone is used.
|
||||
*/
|
||||
DateTime.fromDateAndTime(Date date, Time time, TimeZone timeZone);
|
||||
|
||||
/**
|
||||
* Constructs a new [DateTime] instance with current date time value.
|
||||
* The [timeZone] of this instance is set to the local time-zone.
|
||||
@@ -72,16 +89,6 @@ interface DateTime extends Comparable factory DateTimeImplementation {
|
||||
*/
|
||||
DateTime changeTimeZone(TimeZone targetTimeZone);
|
||||
|
||||
/**
|
||||
* Returns the date.
|
||||
*/
|
||||
Date get date();
|
||||
|
||||
/**
|
||||
* Returns the time.
|
||||
*/
|
||||
Time get time();
|
||||
|
||||
/**
|
||||
* Returns the year.
|
||||
*/
|
||||
@@ -93,7 +100,7 @@ interface DateTime extends Comparable factory DateTimeImplementation {
|
||||
int get month();
|
||||
|
||||
/**
|
||||
* Returns the date in the month [1..31].
|
||||
* Returns the day in the month [1..31].
|
||||
*/
|
||||
int get day();
|
||||
|
||||
@@ -118,7 +125,7 @@ interface DateTime extends Comparable factory DateTimeImplementation {
|
||||
int get milliseconds();
|
||||
|
||||
/**
|
||||
* Returns the week day [Date.MON..Date.SUN]
|
||||
* Returns the week day [MON..SUN]
|
||||
*/
|
||||
int get weekday();
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
{
|
||||
'sources': [
|
||||
'array.dart',
|
||||
'date_implementation.dart',
|
||||
'dual_pivot_quicksort.dart',
|
||||
'exceptions.dart',
|
||||
'hash_map_set.dart',
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Dart core library.
|
||||
|
||||
class DateImplementation implements Date {
|
||||
final int year;
|
||||
final int month;
|
||||
final int day;
|
||||
|
||||
const DateImplementation(int year, int month, int day)
|
||||
: this.year = year,
|
||||
this.month = month,
|
||||
this.day = day;
|
||||
|
||||
bool operator ==(other) {
|
||||
if (this === other) return true;
|
||||
if (!(other is DateImplementation)) return false;
|
||||
return year == other.year && month == other.month && day == other.day;
|
||||
}
|
||||
|
||||
int hashCode() {
|
||||
return approximateDays_(this);
|
||||
}
|
||||
|
||||
static int approximateDays_(Date date) {
|
||||
// Compute the approximate number of days of the given date.
|
||||
// The number is constructed in such a way that year has precedence over
|
||||
// month over day. That is, for two given dates, the returned number is
|
||||
// higher for the date with the higher year, month, day.
|
||||
//
|
||||
// Since a month has at most 31 days, month * 32 ensures that months take
|
||||
// precedence over days. Similarly year * 512 ensures that years take
|
||||
// precedence over months: there are at most 12 months, and 12 * 32 < 512.
|
||||
return date.year * 512 + date.month * 32 + date.day;
|
||||
}
|
||||
|
||||
int compareTo(Date other) {
|
||||
return approximateDays_(this).compareTo(approximateDays_(other));
|
||||
}
|
||||
|
||||
String toString() {
|
||||
String twoDigits(int n) {
|
||||
if (n >= 10) return "${n}";
|
||||
return "0${n}";
|
||||
}
|
||||
String twoDigitMonth = twoDigits(month);
|
||||
String twoDigitDay = twoDigits(day);
|
||||
return "${year}-${twoDigitMonth}-${twoDigitDay}";
|
||||
}
|
||||
|
||||
// TODO(floitsch): Implement missing Date interface.
|
||||
int get weekday() {
|
||||
throw "DateImplementation 'get weekday' unimplemented";
|
||||
}
|
||||
}
|
||||
+18
-28
@@ -55,23 +55,6 @@ class DateTimeImplementation implements DateTime {
|
||||
years, month, day, hours, minutes, seconds, milliseconds,
|
||||
timeZone.isUtc) {}
|
||||
|
||||
factory DateTimeImplementation.fromDateAndTime(
|
||||
Date date,
|
||||
Time time,
|
||||
TimeZoneImplementation timeZone) {
|
||||
if (timeZone === null) {
|
||||
timeZone = new TimeZoneImplementation.local();
|
||||
}
|
||||
return new DateTimeImplementation.withTimeZone(date.year,
|
||||
date.month,
|
||||
date.day + time.days,
|
||||
time.hours,
|
||||
time.minutes,
|
||||
time.seconds,
|
||||
time.milliseconds,
|
||||
timeZone);
|
||||
}
|
||||
|
||||
DateTimeImplementation.now()
|
||||
: timeZone = new TimeZone.local(),
|
||||
value = getCurrentMs_() {
|
||||
@@ -150,14 +133,6 @@ class DateTimeImplementation implements DateTime {
|
||||
return new DateTime.fromEpoch(value, targetTimeZone);
|
||||
}
|
||||
|
||||
Date get date() {
|
||||
return new DateImplementation(year, month, day);
|
||||
}
|
||||
|
||||
Time get time() {
|
||||
return new TimeImplementation(0, hours, minutes, seconds, milliseconds);
|
||||
}
|
||||
|
||||
int get year() {
|
||||
int secondsSinceEpoch = secondsSinceEpoch_;
|
||||
// According to V8 some library calls have troubles with negative values.
|
||||
@@ -219,11 +194,26 @@ class DateTimeImplementation implements DateTime {
|
||||
}
|
||||
|
||||
String toString() {
|
||||
// TODO(floitsch): switch to string-interpolation.
|
||||
String threeDigits(int n) {
|
||||
if (n >= 100) return "${n}";
|
||||
if (n > 10) return "0${n}";
|
||||
return "00${n}";
|
||||
}
|
||||
String twoDigits(int n) {
|
||||
if (n >= 10) return "${n}";
|
||||
return "0${n}";
|
||||
}
|
||||
|
||||
String m = twoDigits(month);
|
||||
String d = twoDigits(day);
|
||||
String h = twoDigits(hours);
|
||||
String min = twoDigits(minutes);
|
||||
String sec = twoDigits(seconds);
|
||||
String ms = threeDigits(milliseconds);
|
||||
if (timeZone.isUtc) {
|
||||
return date.toString() + " " + time.toString() + "Z";
|
||||
return "$year-$m-$d $h:$min:$sec.${ms}Z";
|
||||
} else {
|
||||
return date.toString() + " " + time.toString();
|
||||
return "$year-$m-$d $h:$min:$sec.$ms";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,32 @@ LangGuideTest/08_Expressions/08_17_Function_Invocation_Expression/Named_Argument
|
||||
LangGuideTest/08_Expressions/08_17_Function_Invocation_Expression/Named_Arguments/A03/t01: Fail # Bug 5371670.
|
||||
LangGuideTest/08_Expressions/08_2_Assignment_Operator/Variable_Or_Parameter_Assignment/A03/t04: Fail # Bug 5371670.
|
||||
LibTest/core/Array/length/Array/length/A01/t02: Fail # Bug 5371670.
|
||||
LibTest/core/Date/Date/Date/A01/t03: Fail # Bug 5371670.
|
||||
LibTest/core/Date/Date/Date/A01/t04: Fail # Bug 5371670.
|
||||
|
||||
# The Date class has been removed.
|
||||
LibTest/core/Date/Date/Date/A01/t01: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t02: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t03: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t04: Skip
|
||||
LibTest/core/Date/day/Date/day/A01/t01 : Skip
|
||||
LibTest/core/Date/day/Date/day/A01/t02 : Skip
|
||||
LibTest/core/Date/day/Date/day/A01/t03 : Skip
|
||||
LibTest/core/Date/compareTo/Date/compareTo/A01/t01 : Skip
|
||||
LibTest/core/Date/compareTo/Date/compareTo/A01/t02 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t01 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t02 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t03 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t04 : Skip
|
||||
LibTest/core/Date/month/Date/month/A01/t01 : Skip
|
||||
LibTest/core/Date/month/Date/month/A01/t02 : Skip
|
||||
LibTest/core/Date/month/Date/month/A01/t03 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t01 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t02 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t03 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t04 : Skip
|
||||
LibTest/core/Date/toString/Date/toString/A01/t01 : Skip
|
||||
LibTest/core/Date/year/Date/year/A01/t01 : Skip
|
||||
LibTest/core/Date/year/Date/year/A01/t02 : Skip
|
||||
|
||||
LibTest/core/DateTime/DateTime/DateTime/A01/t02: Fail # Bug 5371670.
|
||||
LibTest/core/DateTime/DateTime/DateTime/A01/t04: Fail # Bug 5371670.
|
||||
LibTest/core/DateTime/DateTime/DateTime/A01/t03: Fail # Bug 5371670.
|
||||
|
||||
@@ -114,7 +114,31 @@ LangGuideTest/02_Language_Constructs/02_5_Meaning_of_Names/Shadowing_and_Hiding_
|
||||
LangGuideTest/02_Language_Constructs/02_5_Meaning_of_Names/Shadowing_and_Hiding_Names/A02/t01: Fail # Bug 5371433
|
||||
LangGuideTest/02_Language_Constructs/02_8_Static_Methods/A02/t02: Fail # Bug 5371433
|
||||
LibTest/core/Array/length/Array/length/A01/t02: Fail # Bug 5371433
|
||||
LibTest/core/Date/Date/Date/A01/t03: Fail # Bug 5371433
|
||||
|
||||
# The Date class has been removed.
|
||||
LibTest/core/Date/Date/Date/A01/t01: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t02: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t03: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t04: Skip
|
||||
LibTest/core/Date/day/Date/day/A01/t01 : Skip
|
||||
LibTest/core/Date/day/Date/day/A01/t02 : Skip
|
||||
LibTest/core/Date/day/Date/day/A01/t03 : Skip
|
||||
LibTest/core/Date/compareTo/Date/compareTo/A01/t01 : Skip
|
||||
LibTest/core/Date/compareTo/Date/compareTo/A01/t02 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t01 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t02 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t03 : Skip
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t04 : Skip
|
||||
LibTest/core/Date/month/Date/month/A01/t01 : Skip
|
||||
LibTest/core/Date/month/Date/month/A01/t02 : Skip
|
||||
LibTest/core/Date/month/Date/month/A01/t03 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t01 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t02 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t03 : Skip
|
||||
LibTest/core/Date/Date/Date/Date/A01/t04 : Skip
|
||||
LibTest/core/Date/toString/Date/toString/A01/t01 : Skip
|
||||
LibTest/core/Date/year/Date/year/A01/t01 : Skip
|
||||
LibTest/core/Date/year/Date/year/A01/t02 : Skip
|
||||
|
||||
|
||||
# The illegal constructor initializer in this test does not get compiled.
|
||||
@@ -212,7 +236,6 @@ LangGuideTest/08_Expressions/08_3_Compound_Assigment_Operators/Unqualified_Compo
|
||||
# These tests are failing in some configurations and not in others.
|
||||
# Filed bug 5309058 to track this.
|
||||
LangGuideTest/08_Expressions/08_2_Assignment_Operator/Variable_Or_Parameter_Assignment/A03/t04: Skip
|
||||
LibTest/core/Date/Date/Date/A01/t04: Skip
|
||||
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t10: Skip
|
||||
LibTest/core/DoubleLinkedList/every/DoubleLinkedList/every/A01/t08: Skip
|
||||
LibTest/core/DoubleLinkedList/filter/DoubleLinkedList/filter/A01/t08: Skip
|
||||
@@ -278,9 +301,6 @@ LibTest/core/Array/some/Array/some/A01/t01: Fail
|
||||
LibTest/core/Array/toArray/Array/toArray/A01/t01: Fail
|
||||
LibTest/core/Array/toSet/Array/toSet/A01/t01: Fail
|
||||
LibTest/core/Array/toSet/Array/toSet/A01/t03: Fail
|
||||
LibTest/core/Date/day/Date/day/A01/t03: Fail
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t01: Fail
|
||||
LibTest/core/Date/weekday/Date/weekday/A01/t04: Fail
|
||||
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t01: Fail
|
||||
LibTest/core/DoubleLinkedList/every/DoubleLinkedList/every/A01/t03: Fail
|
||||
LibTest/core/DoubleLinkedList/filter/DoubleLinkedList/filter/A01/t03: Fail
|
||||
|
||||
@@ -36,15 +36,6 @@ class DateTimeTest {
|
||||
Expect.equals(46, dt.minutes);
|
||||
Expect.equals(40, dt.seconds);
|
||||
Expect.equals(1, dt.milliseconds);
|
||||
Date d = dt.date;
|
||||
Expect.equals(33658, d.year);
|
||||
Expect.equals(9, d.month);
|
||||
Expect.equals(27, d.day);
|
||||
Time t = dt.time;
|
||||
Expect.equals(1, t.hours);
|
||||
Expect.equals(46, t.minutes);
|
||||
Expect.equals(40, t.seconds);
|
||||
Expect.equals(1, t.milliseconds);
|
||||
dt = new DateTime.fromEpoch(-1000000000000001, const TimeZone.utc());
|
||||
Expect.equals(-29719, dt.year);
|
||||
Expect.equals(4, dt.month);
|
||||
@@ -53,15 +44,6 @@ class DateTimeTest {
|
||||
Expect.equals(13, dt.minutes);
|
||||
Expect.equals(19, dt.seconds);
|
||||
Expect.equals(999, dt.milliseconds);
|
||||
d = dt.date;
|
||||
Expect.equals(-29719, d.year);
|
||||
Expect.equals(4, d.month);
|
||||
Expect.equals(5, d.day);
|
||||
t = dt.time;
|
||||
Expect.equals(22, t.hours);
|
||||
Expect.equals(13, t.minutes);
|
||||
Expect.equals(19, t.seconds);
|
||||
Expect.equals(999, t.milliseconds);
|
||||
// Same with local zone.
|
||||
dt = new DateTime.fromEpoch(1000000000000001, new TimeZone.local());
|
||||
Expect.equals(33658, dt.year);
|
||||
@@ -216,8 +198,9 @@ class DateTimeTest {
|
||||
(2034 == dt.year && 12 == dt.month && 31 == dt.day));
|
||||
Expect.equals(0, dt.seconds);
|
||||
Expect.equals(1, dt.milliseconds);
|
||||
DateTime dt2 = new DateTime.fromDateAndTime(dt.date, dt.time,
|
||||
new TimeZone.local());
|
||||
DateTime dt2 = new DateTime.withTimeZone(
|
||||
dt.year, dt.month, dt.day, dt.hours, dt.minutes, dt.seconds,
|
||||
dt.milliseconds, new TimeZone.local());
|
||||
Expect.equals(dt.value, dt2.value);
|
||||
dt = new DateTime.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1,
|
||||
new TimeZone.local());
|
||||
@@ -225,7 +208,9 @@ class DateTimeTest {
|
||||
(2034 == dt.year && 12 == dt.month && 31 == dt.day));
|
||||
Expect.equals(59, dt.seconds);
|
||||
Expect.equals(999, dt.milliseconds);
|
||||
dt2 = new DateTime.fromDateAndTime(dt.date, dt.time, new TimeZone.local());
|
||||
dt2 = new DateTime.withTimeZone(
|
||||
dt.year, dt.month, dt.day, dt.hours, dt.minutes, dt.seconds,
|
||||
dt.milliseconds, new TimeZone.local());
|
||||
Expect.equals(dt.value, dt2.value);
|
||||
}
|
||||
|
||||
@@ -240,16 +225,6 @@ class DateTimeTest {
|
||||
Expect.equals(0, dt.milliseconds);
|
||||
Expect.equals(true, const TimeZone.utc() == dt.timeZone);
|
||||
Expect.equals(1305140315000, dt.value);
|
||||
Date d = dt.date;
|
||||
Expect.equals(2011, d.year);
|
||||
Expect.equals(5, d.month);
|
||||
Expect.equals(11, d.day);
|
||||
Time t = dt.time;
|
||||
Expect.equals(0, t.days);
|
||||
Expect.equals(18, t.hours);
|
||||
Expect.equals(58, t.minutes);
|
||||
Expect.equals(35, t.seconds);
|
||||
Expect.equals(0, t.milliseconds);
|
||||
dt = new DateTime.fromEpoch(-9999999, const TimeZone.utc());
|
||||
Expect.equals(1969, dt.year);
|
||||
Expect.equals(12, dt.month);
|
||||
@@ -258,15 +233,6 @@ class DateTimeTest {
|
||||
Expect.equals(13, dt.minutes);
|
||||
Expect.equals(20, dt.seconds);
|
||||
Expect.equals(1, dt.milliseconds);
|
||||
d = dt.date;
|
||||
Expect.equals(1969, d.year);
|
||||
Expect.equals(12, d.month);
|
||||
Expect.equals(31, d.day);
|
||||
t = dt.time;
|
||||
Expect.equals(21, t.hours);
|
||||
Expect.equals(13, t.minutes);
|
||||
Expect.equals(20, t.seconds);
|
||||
Expect.equals(1, t.milliseconds);
|
||||
}
|
||||
|
||||
static void testLocalGetters() {
|
||||
@@ -294,12 +260,13 @@ class DateTimeTest {
|
||||
|
||||
static void testConstructors() {
|
||||
var dt1 = new DateTime.fromEpoch(1305140315000, new TimeZone.local());
|
||||
Date d = dt1.date;
|
||||
Time t = dt1.time;
|
||||
var dt3 = new DateTime.fromDateAndTime(d, t, null);
|
||||
var dt3 = new DateTime(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 DateTime.fromDateAndTime(d, t, new TimeZone.local());
|
||||
dt3 = new DateTime.withTimeZone(
|
||||
dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
|
||||
dt1.seconds, dt1.milliseconds, new TimeZone.local());
|
||||
Expect.equals(dt1.value, dt3.value);
|
||||
Expect.equals(true, dt1 == dt3);
|
||||
dt3 = new DateTime.withTimeZone(2011, 5, 11, 18, 58, 35, 0,
|
||||
@@ -313,9 +280,9 @@ class DateTimeTest {
|
||||
Expect.equals(dt2.value, dt3.value);
|
||||
Expect.equals(true, dt2 == dt3);
|
||||
dt1 = new DateTime.fromEpoch(-9999999, const TimeZone.utc());
|
||||
d = dt1.date;
|
||||
t = dt1.time;
|
||||
dt3 = new DateTime.fromDateAndTime(d, t, const TimeZone.utc());
|
||||
dt3 = new DateTime.withTimeZone(
|
||||
dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
|
||||
dt1.seconds, dt1.milliseconds, const TimeZone.utc());
|
||||
Expect.equals(dt1.value, dt3.value);
|
||||
}
|
||||
|
||||
@@ -325,17 +292,29 @@ class DateTimeTest {
|
||||
Expect.equals(dt1.value, dt2.value);
|
||||
var dt3 = new DateTime.fromEpoch(1305140315000, const TimeZone.utc());
|
||||
Expect.equals(dt1.value, dt3.value);
|
||||
Expect.equals(true, dt2.date == dt3.date);
|
||||
Expect.equals(true, dt2.time == dt3.time);
|
||||
Expect.equals(dt2.year, dt3.year);
|
||||
Expect.equals(dt2.month, dt3.month);
|
||||
Expect.equals(dt2.day, dt3.day);
|
||||
Expect.equals(dt2.hours, dt3.hours);
|
||||
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());
|
||||
Expect.equals(true, dt1.date == dt4.date);
|
||||
Expect.equals(true, dt1.time == dt4.time);
|
||||
Expect.equals(dt1.year, dt4.year);
|
||||
Expect.equals(dt1.month, dt4.month);
|
||||
Expect.equals(dt1.day, dt4.day);
|
||||
Expect.equals(dt1.hours, dt4.hours);
|
||||
Expect.equals(dt1.minutes, dt4.minutes);
|
||||
Expect.equals(dt1.seconds, dt4.seconds);
|
||||
Expect.equals(dt1.milliseconds, dt4.milliseconds);
|
||||
}
|
||||
|
||||
static void testSubAdd() {
|
||||
var dt1 = new DateTime.fromEpoch(1305140315000, const TimeZone.utc());
|
||||
var dt2 = dt1.add(const Time.duration(3 * Time.MS_PER_SECOND + 5));
|
||||
Expect.equals(true, dt1.date == dt2.date);
|
||||
Expect.equals(dt1.year, dt2.year);
|
||||
Expect.equals(dt1.month, dt2.month);
|
||||
Expect.equals(dt1.day, dt2.day);
|
||||
Expect.equals(dt1.hours, dt2.hours);
|
||||
Expect.equals(dt1.minutes, dt2.minutes);
|
||||
Expect.equals(dt1.seconds + 3, dt2.seconds);
|
||||
|
||||
Reference in New Issue
Block a user