Rename DateTime to Date.

Review URL: https://chromereviews.googleplex.com/3529013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@107 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
floitsch@google.com 2011-10-06 10:14:49 +00:00
parent eebda50623
commit 15727ed074
46 changed files with 362 additions and 352 deletions

View file

@ -123,7 +123,7 @@ class AnimationScheduler {
_setupInterval();
}
int numRemaining = 0;
int minTime = new DateTime.now().value + MS_PER_FRAME;
int minTime = new Date.now().value + MS_PER_FRAME;
int len = _callbacks.length;
for (final callback in _callbacks) {

View file

@ -6,7 +6,7 @@
class BenchUtil {
static int get now() {
return new DateTime.now().value;
return new Date.now().value;
}
static Map<String, Object> deserialize(String data) {

View file

@ -58,12 +58,12 @@ class Suite {
// more smoothly as well.
for (int i = 0; i < _N_RUNS; i++) {
int runs = 0;
final int start = new DateTime.now().value;
final int start = new Date.now().value;
int cur = new DateTime.now().value;
int cur = new Date.now().value;
while ((cur - start) < 1000) {
test();
cur = new DateTime.now().value;
cur = new Date.now().value;
runs++;
}

View file

@ -10,7 +10,7 @@ interface File extends Blob {
int get fileSize();
DateTime get lastModifiedDate();
Date get lastModifiedDate();
String get name();
}

View file

@ -164,9 +164,9 @@ interface HTMLInputElement extends HTMLElement {
void set value(String value);
DateTime get valueAsDate();
Date get valueAsDate();
void set valueAsDate(DateTime value);
void set valueAsDate(Date value);
num get valueAsNumber();

View file

@ -6,5 +6,5 @@
interface Metadata {
DateTime get modificationTime();
Date get modificationTime();
}

View file

@ -17,8 +17,8 @@ class _FileWrappingImplementation extends _BlobWrappingImplementation implements
int get fileSize() { return _get__File_fileSize(this); }
static int _get__File_fileSize(var _this) native;
DateTime get lastModifiedDate() { return _get__File_lastModifiedDate(this); }
static DateTime _get__File_lastModifiedDate(var _this) native;
Date get lastModifiedDate() { return _get__File_lastModifiedDate(this); }
static Date _get__File_lastModifiedDate(var _this) native;
String get name() { return _get__File_name(this); }
static String _get__File_name(var _this) native;

View file

@ -248,11 +248,11 @@ class _HTMLInputElementWrappingImplementation extends _HTMLElementWrappingImplem
void set value(String value) { _set__HTMLInputElement_value(this, value); }
static void _set__HTMLInputElement_value(var _this, String value) native;
DateTime get valueAsDate() { return _get__HTMLInputElement_valueAsDate(this); }
static DateTime _get__HTMLInputElement_valueAsDate(var _this) native;
Date get valueAsDate() { return _get__HTMLInputElement_valueAsDate(this); }
static Date _get__HTMLInputElement_valueAsDate(var _this) native;
void set valueAsDate(DateTime value) { _set__HTMLInputElement_valueAsDate(this, value); }
static void _set__HTMLInputElement_valueAsDate(var _this, DateTime value) native;
void set valueAsDate(Date value) { _set__HTMLInputElement_valueAsDate(this, value); }
static void _set__HTMLInputElement_valueAsDate(var _this, Date value) native;
num get valueAsNumber() { return _get__HTMLInputElement_valueAsNumber(this); }
static num _get__HTMLInputElement_valueAsNumber(var _this) native;

View file

@ -11,8 +11,8 @@ class _MetadataWrappingImplementation extends DOMWrapperBase implements Metadata
return new _MetadataWrappingImplementation();
}
DateTime get modificationTime() { return _get__Metadata_modificationTime(this); }
static DateTime _get__Metadata_modificationTime(var _this) native;
Date get modificationTime() { return _get__Metadata_modificationTime(this); }
static Date _get__Metadata_modificationTime(var _this) native;
String get typeName() { return "Metadata"; }
}

View file

@ -6,7 +6,7 @@
class BenchUtil {
static int get now() {
return new DateTime.now().value;
return new Date.now().value;
}
static Map<String, Object> deserialize(String data) {

View file

@ -55,12 +55,12 @@ class Suite {
// more smoothly as well.
for (int i = 0; i < _N_RUNS; i++) {
int runs = 0;
final int start = new DateTime.now().value;
final int start = new Date.now().value;
int cur = new DateTime.now().value;
int cur = new Date.now().value;
while ((cur - start) < 1000) {
test();
cur = new DateTime.now().value;
cur = new Date.now().value;
runs++;
}

View file

@ -10,7 +10,7 @@ interface File extends Blob {
int get fileSize();
DateTime get lastModifiedDate();
Date get lastModifiedDate();
String get name();
}

View file

@ -164,9 +164,9 @@ interface InputElement extends Element {
void set value(String value);
DateTime get valueAsDate();
Date get valueAsDate();
void set valueAsDate(DateTime value);
void set valueAsDate(Date value);
num get valueAsNumber();

View file

@ -6,5 +6,5 @@
interface Metadata {
DateTime get modificationTime();
Date get modificationTime();
}

View file

@ -11,7 +11,7 @@ class FileWrappingImplementation extends BlobWrappingImplementation implements F
int get fileSize() { return _ptr.fileSize; }
DateTime get lastModifiedDate() { return _ptr.lastModifiedDate; }
Date get lastModifiedDate() { return _ptr.lastModifiedDate; }
String get name() { return _ptr.name; }

View file

@ -165,9 +165,9 @@ class InputElementWrappingImplementation extends ElementWrappingImplementation i
void set value(String value) { _ptr.value = value; }
DateTime get valueAsDate() { return _ptr.valueAsDate; }
Date get valueAsDate() { return _ptr.valueAsDate; }
void set valueAsDate(DateTime value) { _ptr.valueAsDate = value; }
void set valueAsDate(Date value) { _ptr.valueAsDate = value; }
num get valueAsNumber() { return _ptr.valueAsNumber; }

View file

@ -7,7 +7,7 @@
class MetadataWrappingImplementation extends DOMWrapperBase implements Metadata {
MetadataWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
DateTime get modificationTime() { return _ptr.modificationTime; }
Date get modificationTime() { return _ptr.modificationTime; }
String get typeName() { return "Metadata"; }
}

View file

@ -9,6 +9,6 @@
*/
class TimeUtil {
static int now() {
return new DateTime.now().value;
return new Date.now().value;
}
}

View file

@ -5,22 +5,22 @@
/**
* General purpose date/time utilities.
*/
class DateTimeUtils {
class DateUtils {
// TODO(jmesserly): localized strings
static final WEEKDAYS = const ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday', 'Sunday'];
static final YESTERDAY = 'Yesterday';
static final MS_IN_WEEK = DateTime.DAYS_IN_WEEK * Time.MS_PER_DAY;
static final MS_IN_WEEK = Date.DAYS_IN_WEEK * Time.MS_PER_DAY;
// TODO(jmesserly): workaround for missing DateTime.fromDate in Dartium
// TODO(jmesserly): workaround for missing Date.fromDate in Dartium
// Remove this once that is implemented. See b/5055106
// Parse a string like: "Mon, 27 Jun 2011 15:22:00 -0700"
static DateTime fromString(String text) {
static Date fromString(String text) {
final parts = text.split(' ');
if (parts.length == 1) {
return _parseIsoDateTime(text);
return _parseIsoDate(text);
}
if (parts.length != 6) {
@ -55,7 +55,7 @@ class DateTimeUtils {
int zoneOffset = Math.parseInt(parts[5]) ~/ 100;
// Pretend it's a UTC time
DateTime result = new DateTime.withTimeZone(
Date result = new Date.withTimeZone(
year, month, day, hours, minutes, seconds, 0, new TimeZone.utc());
// Shift it to the proper zone, but it's still a UTC time
result = result.subtract(new Time(0, zoneOffset, 0, 0, 0));
@ -64,11 +64,11 @@ class DateTimeUtils {
}
/** Parse a string like: 2011-07-19T22:03:04.000Z */
// TODO(jmesserly): workaround for DateTime.fromDate, which has issues:
// TODO(jmesserly): workaround for Date.fromDate, which has issues:
// * on Dart VM it doesn't handle all of ISO 8601. See b/5055106.
// * on DartC it doesn't work on Safari. See b/5062557.
// Remove this once that function is fully implemented
static DateTime _parseIsoDateTime(String text) {
static Date _parseIsoDate(String text) {
void ensure(bool value) {
if (!value) {
throw 'bad date format, expected YYYY-MM-DDTHH:MM:SS.mmmZ: ' + text;
@ -99,7 +99,7 @@ class DateTimeUtils {
milliseconds = Math.parseInt(seconds[1]);
}
return new DateTime.withTimeZone(
return new Date.withTimeZone(
Math.parseInt(date[0]),
Math.parseInt(date[1]),
Math.parseInt(date[2]),
@ -117,19 +117,19 @@ class DateTimeUtils {
* - if it's from the same week, just show the weekday
* - otherwise, show just the date
*/
static String toRecentTimeString(DateTime then) {
bool datesAreEqual(DateTime d1, DateTime d2) {
static String toRecentTimeString(Date then) {
bool datesAreEqual(Date d1, Date d2) {
return (d1.year == d2.year) && (d1.month == d2.month) &&
(d1.day == d2.day);
}
final now = new DateTime.now();
final now = new Date.now();
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);
final today = new Date(now.year, now.month, now.day, 0, 0, 0, 0);
Time delta = today.difference(then);
if (delta.duration < Time.MS_PER_DAY) {
return YESTERDAY;
@ -147,14 +147,14 @@ class DateTimeUtils {
}
}
// TODO(jmesserly): this is a workaround for unimplemented DateTime.weekday
// TODO(jmesserly): this is a workaround for unimplemented Date.weekday
// Code inspired by v8/src/date.js
static int getWeekday(DateTime dateTime) {
final unixTimeStart = new DateTime(1970, 1, 1, 0, 0, 0, 0);
static int getWeekday(Date dateTime) {
final unixTimeStart = new Date(1970, 1, 1, 0, 0, 0, 0);
int msSince1970 = dateTime.difference(unixTimeStart).duration;
int daysSince1970 = msSince1970 ~/ Time.MS_PER_DAY;
// 1970-1-1 was Thursday
return ((daysSince1970 + DateTime.THU) % DateTime.DAYS_IN_WEEK);
return ((daysSince1970 + Date.THU) % Date.DAYS_IN_WEEK);
}
/** Formats a time in H:MM A format */

View file

@ -7,6 +7,6 @@
#import('../observable/observable.dart');
#source('CollectionUtils.dart');
#source('DateTimeUtils.dart');
#source('DateUtils.dart');
#source('StringUtils.dart');
#source('Uri.dart');

View file

@ -12,7 +12,7 @@ class Clock {
* Returns the current clock tick.
*/
static int now() {
return new DateTime.now().value;
return new Date.now().value;
}
/**

View file

@ -13,7 +13,7 @@
#source("src/bool.dart");
#source("src/collection.dart");
#source("src/comparable.dart");
#source("src/date_time.dart");
#source("src/date.dart");
#source("src/double.dart");
#source("src/exceptions.dart");
#source("src/expect.dart");

View file

@ -10,7 +10,7 @@
#source("implementation/arrays.dart");
#source("implementation/bool.dart");
#source("implementation/collections.dart");
#source("implementation/date_time_implementation.dart");
#source("implementation/date_implementation.dart");
#source("implementation/isolate.dart");
#source("implementation/isolate_serialization.dart");
#source("implementation/math_natives.dart");
@ -35,7 +35,7 @@
#native("implementation/array.js");
#native("implementation/bool.js");
#native("implementation/core.js");
#native("implementation/date_time_implementation.js");
#native("implementation/date_implementation.js");
#native("implementation/isolate.js");
#native("implementation/math_natives.js");
#native("implementation/number.js");

View file

@ -4,61 +4,61 @@
// Dart core library.
// JavaScript implementation of DateTimeImplementation.
class DateTimeImplementation implements DateTime {
factory DateTimeImplementation(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds) {
return new DateTimeImplementation.withTimeZone(
// JavaScript implementation of DateImplementation.
class DateImplementation implements Date {
factory DateImplementation(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds) {
return new DateImplementation.withTimeZone(
years, month, day,
hours, minutes, seconds, milliseconds,
new TimeZoneImplementation.local());
}
DateTimeImplementation.withTimeZone(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
TimeZoneImplementation timeZone)
DateImplementation.withTimeZone(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
TimeZoneImplementation timeZone)
: this.timeZone = timeZone,
value = _valueFromDecomposed(years, month, day,
hours, minutes, seconds, milliseconds,
timeZone.isUtc) {
}
DateTimeImplementation.now()
DateImplementation.now()
: timeZone = new TimeZone.local(),
value = _now() {
}
DateTimeImplementation.fromString(String formattedString)
DateImplementation.fromString(String formattedString)
: timeZone = new TimeZone.local(),
value = _valueFromString(formattedString) {
}
const DateTimeImplementation.fromEpoch(this.value, this.timeZone);
const DateImplementation.fromEpoch(this.value, this.timeZone);
bool operator ==(other) {
if (!(other is DateTimeImplementation)) return false;
if (!(other is DateImplementation)) return false;
return (value == other.value) && (timeZone == other.timeZone);
}
int compareTo(DateTime other) {
int compareTo(Date other) {
return value.compareTo(other.value);
}
DateTime changeTimeZone(TimeZone targetTimeZone) {
Date changeTimeZone(TimeZone targetTimeZone) {
if (targetTimeZone == null) {
targetTimeZone = new TimeZoneImplementation.local();
}
return new DateTime.fromEpoch(value, targetTimeZone);
return new Date.fromEpoch(value, targetTimeZone);
}
int get year() {
@ -125,20 +125,18 @@ class DateTimeImplementation implements DateTime {
}
}
// Adds the duration [time] to this DateTime instance.
DateTime add(Time time) {
return new DateTimeImplementation.fromEpoch(value + time.duration,
timeZone);
// Adds the duration [time] to this Date instance.
Date add(Time time) {
return new DateImplementation.fromEpoch(value + time.duration, timeZone);
}
// Subtracts the duration [time] from this DateTime instance.
DateTime subtract(Time time) {
return new DateTimeImplementation.fromEpoch(value - time.duration,
timeZone);
// Subtracts the duration [time] from this Date instance.
Date subtract(Time time) {
return new DateImplementation.fromEpoch(value - time.duration, timeZone);
}
// Returns a [Time] with the difference of [this] and [other].
Time difference(DateTime other) {
Time difference(Date other) {
return new TimeImplementation.duration(value - other.value);
}

View file

@ -4,15 +4,15 @@
// Dart core library.
function dateTime$validateValue(value) {
function date$validateValue(value) {
if (isNaN(value)) {
// TODO(floitsch): Use real exception object.
throw "Invalid DateTime";
throw Error("Invalid Date");
}
return value;
}
function native_DateTimeImplementation__valueFromDecomposed(
function native_DateImplementation__valueFromDecomposed(
years, month, day, hours, minutes, seconds, milliseconds, isUtc) {
// JavaScript has 0-based months.
var jsMonth = month - 1;
@ -21,60 +21,60 @@ function native_DateTimeImplementation__valueFromDecomposed(
hours, minutes, seconds, milliseconds) :
new Date(years, jsMonth, day,
hours, minutes, seconds, milliseconds).valueOf();
return dateTime$validateValue(value);
return date$validateValue(value);
}
function native_DateTimeImplementation__valueFromString(str) {
return dateTime$validateValue(Date.parse(str));
function native_DateImplementation__valueFromString(str) {
return date$validateValue(Date.parse(str));
}
function native_DateTimeImplementation__now() {
function native_DateImplementation__now() {
return new Date().valueOf();
}
function dateTime$dateFrom(dartDateTime, value) {
function date$dateFrom(dartDate, value) {
// Lazily keep a JS Date stored in the dart object.
var date = dartDateTime.date;
var date = dartDate.date;
if (!date) {
date = new Date(value);
dartDateTime.date = date;
dartDate.date = date;
}
return date;
}
function native_DateTimeImplementation__getYear(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getYear(value, isUtc) {
var date = date$dateFrom(this, value);
return isUtc ? date.getUTCFullYear() : date.getFullYear();
}
function native_DateTimeImplementation__getMonth(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getMonth(value, isUtc) {
var date = date$dateFrom(this, value);
var jsMonth = isUtc ? date.getUTCMonth() : date.getMonth();
// JavaScript has 0-based months.
return jsMonth + 1;
}
function native_DateTimeImplementation__getDay(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getDay(value, isUtc) {
var date = date$dateFrom(this, value);
return isUtc ? date.getUTCDate() : date.getDate();
}
function native_DateTimeImplementation__getHours(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getHours(value, isUtc) {
var date = date$dateFrom(this, value);
return isUtc ? date.getUTCHours() : date.getHours();
}
function native_DateTimeImplementation__getMinutes(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getMinutes(value, isUtc) {
var date = date$dateFrom(this, value);
return isUtc ? date.getUTCMinutes() : date.getMinutes();
}
function native_DateTimeImplementation__getSeconds(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getSeconds(value, isUtc) {
var date = date$dateFrom(this, value);
return isUtc ? date.getUTCSeconds() : date.getSeconds();
}
function native_DateTimeImplementation__getMilliseconds(value, isUtc) {
var date = dateTime$dateFrom(this, value);
function native_DateImplementation__getMilliseconds(value, isUtc) {
var date = date$dateFrom(this, value);
return isUtc ? date.getUTCMilliseconds() : date.getMilliseconds();
}

View file

@ -7,7 +7,7 @@
'bool.dart',
'collection.dart',
'comparable.dart',
'date_time.dart',
'date.dart',
'double.dart',
'exceptions.dart',
'expect.dart',

View file

@ -5,9 +5,9 @@
// Dart core library.
/**
* DateTime is the public interface to a point in time.
* Date is the public interface to a point in time.
*/
interface DateTime extends Comparable factory DateTimeImplementation {
interface Date extends Comparable factory DateImplementation {
// Weekday constants that are returned by [weekday] method:
static final int MON = 0;
static final int TUE = 1;
@ -33,61 +33,61 @@ interface DateTime extends Comparable factory DateTimeImplementation {
static final int DEC = 12;
/**
* Constructs a [DateTime] instance based on the individual parts, in the
* Constructs a [Date] instance based on the individual parts, in the
* local time-zone.
*/
DateTime(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds);
Date(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds);
/**
* Constructs a [DateTime] instance based on the individual parts.
* Constructs a [Date] instance based on the individual parts.
* [timeZone] may not be [:null:].
*/
DateTime.withTimeZone(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
TimeZone timeZone);
Date.withTimeZone(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
TimeZone timeZone);
/**
* Constructs a new [DateTime] instance with current date time value.
* Constructs a new [Date] instance with current date time value.
* The [timeZone] of this instance is set to the local time-zone.
*/
DateTime.now();
Date.now();
/**
* Constructs a new [DateTime] instance based on [formattedString].
* Constructs a new [Date] instance based on [formattedString].
*/
DateTime.fromString(String formattedString);
Date.fromString(String formattedString);
/**
* Constructs a new [DateTime] instance with the given time zone. The given
* Constructs a new [Date] instance with the given time zone. The given
* [timeZone] must not be [:null:].
*
* This constructor is the only one that doesn't need to be computations and
* which can therefore be [:const:].
*
* The constructed [DateTime] represents 1970-01-01T00:00:00Z + [value]ms in
* The constructed [Date] represents 1970-01-01T00:00:00Z + [value]ms in
* the given [timeZone].
*/
const DateTime.fromEpoch(int value, TimeZone timeZone);
const Date.fromEpoch(int value, TimeZone timeZone);
/**
* Returns a new [DateTime] in the given [targetTimeZone] time zone. The
* Returns a new [Date] in the given [targetTimeZone] time zone. The
* [value] of the new instance is equal to [:this.value:].
*
* This call is equivalent to
* [:new DateTime.fromEpoch(this.value, targetTimeZone):].
* [:new Date.fromEpoch(this.value, targetTimeZone):].
*/
DateTime changeTimeZone(TimeZone targetTimeZone);
Date changeTimeZone(TimeZone targetTimeZone);
/**
* Returns the year.
@ -142,12 +142,12 @@ interface DateTime extends Comparable factory DateTimeImplementation {
final TimeZone timeZone;
/**
* Returns true if this [DateTime] is set to local time.
* Returns true if this [Date] is set to local time.
*/
bool isLocalTime();
/**
* Returns true if this [DateTime] is set to UTC time.
* Returns true if this [Date] is set to UTC time.
* This is equivalent to [:this.timeZone.duration == 0:].
*/
bool isUtc();
@ -159,18 +159,18 @@ interface DateTime extends Comparable factory DateTimeImplementation {
String toString();
/**
* Returns a new [DateTime] with the time [other] added to this instance.
* Returns a new [Date] with the time [other] added to this instance.
*/
DateTime add(Time other);
Date add(Time other);
/**
* Returns a new [DateTime] with the time [other] subtracted from this
* Returns a new [Date] with the time [other] subtracted from this
* instance.
*/
DateTime subtract(Time other);
Date subtract(Time other);
/**
* Returns a [Time] with the difference of [:this:] and [other].
*/
Time difference(DateTime other);
Time difference(Date other);
}

View file

@ -9,7 +9,7 @@ interface TimeZone factory TimeZoneImplementation {
// TODO(floitsch): The interface of this class will most likely change.
// [offset] will probably not be accessible this way. It is much simpler to
// think of TimeZones as locations instead of offsets.
// When constructing a date, one wants to say: give me the DateTime in Paris.
// When constructing a date, one wants to say: give me the Date in Paris.
// The date is then used to determine if it should be CET or CEST.
// However this also means that the offset is depending on an associated
// date.

View file

@ -24,7 +24,7 @@ class _Timer implements Timer {
Timer timer = new _Timer._internal();
timer._callback = callback;
timer._milliSeconds = milliSeconds;
timer._wakeupTime = (new DateTime.now()).value + milliSeconds;
timer._wakeupTime = (new Date.now()).value + milliSeconds;
timer._repeating = repeating;
timer._addTimerToList();
timer._notifyEventHandler();
@ -110,7 +110,7 @@ class _Timer implements Timer {
void _createTimerHandler() {
void _handleTimeout() {
int currentTime = (new DateTime.now()).value + _TIMER_JITTER;
int currentTime = (new Date.now()).value + _TIMER_JITTER;
DoubleLinkedQueueEntry<_Timer> entry = _timers.firstEntry();
DoubleLinkedQueueEntry<_Timer> current;

View file

@ -13,7 +13,7 @@ namespace dart {
static bool BreakDownSecondsSinceEpoch(const Integer& dart_seconds,
const Bool& dart_is_utc,
OS::BrokenDownDateTime* result) {
OS::BrokenDownDate* result) {
bool is_utc = dart_is_utc.value();
int64_t value = dart_seconds.AsInt64Value();
time_t seconds = static_cast<time_t>(value);
@ -21,7 +21,7 @@ static bool BreakDownSecondsSinceEpoch(const Integer& dart_seconds,
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_brokenDownToSecondsSinceEpoch, 7) {
DEFINE_NATIVE_ENTRY(DateNatives_brokenDownToSecondsSinceEpoch, 7) {
const Integer& dart_years = Integer::CheckedHandle(arguments->At(0));
const Smi& dart_month = Smi::CheckedHandle(arguments->At(1));
const Smi& dart_day = Smi::CheckedHandle(arguments->At(2));
@ -34,7 +34,7 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_brokenDownToSecondsSinceEpoch, 7) {
}
Smi& smi_years = Smi::Handle();
smi_years ^= dart_years.raw();
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
// mktime takes the years since 1900.
// TODO(floitsch): Removing 1900 could underflow the intptr_t.
intptr_t year = smi_years.Value() - 1900;
@ -59,17 +59,17 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_brokenDownToSecondsSinceEpoch, 7) {
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_currentTimeMillis, 0) {
DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) {
const Integer& time = Integer::Handle(
Integer::New(OS::GetCurrentTimeMillis()));
arguments->SetReturn(time);
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_getYear, 2) {
DEFINE_NATIVE_ENTRY(DateNatives_getYear, 2) {
const Integer& dart_seconds = Integer::CheckedHandle(arguments->At(0));
const Bool& dart_is_utc = Bool::CheckedHandle(arguments->At(1));
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
bool succeeded =
BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down);
if (!succeeded) {
@ -82,10 +82,10 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_getYear, 2) {
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_getMonth, 2) {
DEFINE_NATIVE_ENTRY(DateNatives_getMonth, 2) {
const Integer& dart_seconds = Integer::CheckedHandle(arguments->At(0));
const Bool& dart_is_utc = Bool::CheckedHandle(arguments->At(1));
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
bool succeeded =
BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down);
if (!succeeded) {
@ -97,10 +97,10 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_getMonth, 2) {
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_getDay, 2) {
DEFINE_NATIVE_ENTRY(DateNatives_getDay, 2) {
const Integer& dart_seconds = Integer::CheckedHandle(arguments->At(0));
const Bool& dart_is_utc = Bool::CheckedHandle(arguments->At(1));
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
bool succeeded =
BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down);
if (!succeeded) {
@ -111,10 +111,10 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_getDay, 2) {
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_getHours, 2) {
DEFINE_NATIVE_ENTRY(DateNatives_getHours, 2) {
const Integer& dart_seconds = Integer::CheckedHandle(arguments->At(0));
const Bool& dart_is_utc = Bool::CheckedHandle(arguments->At(1));
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
bool succeeded =
BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down);
if (!succeeded) {
@ -125,10 +125,10 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_getHours, 2) {
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_getMinutes, 2) {
DEFINE_NATIVE_ENTRY(DateNatives_getMinutes, 2) {
const Integer& dart_seconds = Integer::CheckedHandle(arguments->At(0));
const Bool& dart_is_utc = Bool::CheckedHandle(arguments->At(1));
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
bool succeeded =
BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down);
if (!succeeded) {
@ -139,10 +139,10 @@ DEFINE_NATIVE_ENTRY(DateTimeNatives_getMinutes, 2) {
}
DEFINE_NATIVE_ENTRY(DateTimeNatives_getSeconds, 2) {
DEFINE_NATIVE_ENTRY(DateNatives_getSeconds, 2) {
const Integer& dart_seconds = Integer::CheckedHandle(arguments->At(0));
const Bool& dart_is_utc = Bool::CheckedHandle(arguments->At(1));
OS::BrokenDownDateTime broken_down;
OS::BrokenDownDate broken_down;
bool succeeded =
BreakDownSecondsSinceEpoch(dart_seconds, dart_is_utc, &broken_down);
if (!succeeded) {

View file

@ -27,40 +27,40 @@ class TimeZoneImplementation implements TimeZone {
final bool isUtc;
}
// JavaScript implementation of DateTimeImplementation.
class DateTimeImplementation implements DateTime {
factory DateTimeImplementation(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds) {
return new DateTimeImplementation.withTimeZone(
// JavaScript implementation of DateImplementation.
class DateImplementation implements Date {
factory DateImplementation(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds) {
return new DateImplementation.withTimeZone(
years, month, day,
hours, minutes, seconds, milliseconds,
new TimeZoneImplementation.local());
}
DateTimeImplementation.withTimeZone(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
TimeZoneImplementation timeZone)
DateImplementation.withTimeZone(int years,
int month,
int day,
int hours,
int minutes,
int seconds,
int milliseconds,
TimeZoneImplementation timeZone)
: timeZone = timeZone,
value = brokenDownDateTimeToMillisecondsSinceEpoch_(
value = brokenDownDateToMillisecondsSinceEpoch_(
years, month, day, hours, minutes, seconds, milliseconds,
timeZone.isUtc) {}
DateTimeImplementation.now()
DateImplementation.now()
: timeZone = new TimeZone.local(),
value = getCurrentMs_() {
}
factory DateTimeImplementation.fromString(String formattedString) {
factory DateImplementation.fromString(String formattedString) {
int substringToNumber(String str, int from, int to) {
int result = 0;
for (int i = from; i < to; i++) {
@ -69,7 +69,7 @@ class DateTimeImplementation implements DateTime {
return result;
}
// TODO(floitsch): improve DateTimeImplementation parsing.
// TODO(floitsch): improve DateImplementation parsing.
// Parse ISO 8601: "2011-05-14 00:37:18.231Z".
int yearMonthSeparator = formattedString.indexOf("-", 0);
if (yearMonthSeparator < 0) throw "UNIMPLEMENTED";
@ -110,27 +110,27 @@ class DateTimeImplementation implements DateTime {
secondsMillisecondsSeparator + 1,
end);
TimeZone timeZone = (isUtc ? const TimeZone.utc() : new TimeZone.local());
return new DateTimeImplementation.withTimeZone(
return new DateImplementation.withTimeZone(
year, month, day, hours, minutes, seconds, milliseconds, timeZone);
}
const DateTimeImplementation.fromEpoch(int this.value,
TimeZone this.timeZone);
const DateImplementation.fromEpoch(int this.value,
TimeZone this.timeZone);
bool operator ==(Object other) {
if (!(other is DateTimeImplementation)) return false;
if (!(other is DateImplementation)) return false;
return value == other.value && timeZone == other.timeZone;
}
int compareTo(DateTime other) {
int compareTo(Date other) {
return value.compareTo(other.value);
}
DateTime changeTimeZone(TimeZone targetTimeZone) {
Date changeTimeZone(TimeZone targetTimeZone) {
if (targetTimeZone === null) {
targetTimeZone = new TimeZoneImplementation.local();
}
return new DateTime.fromEpoch(value, targetTimeZone);
return new Date.fromEpoch(value, targetTimeZone);
}
int get year() {
@ -217,20 +217,18 @@ class DateTimeImplementation implements DateTime {
}
}
// Adds the duration [time] to this DateTime instance.
DateTime add(Time time) {
return new DateTimeImplementation.fromEpoch(value + time.duration,
timeZone);
// Adds the duration [time] to this Date instance.
Date add(Time time) {
return new DateImplementation.fromEpoch(value + time.duration, timeZone);
}
// Subtracts the duration [time] from this DateTime instance.
DateTime subtract(Time time) {
return new DateTimeImplementation.fromEpoch(value - time.duration,
timeZone);
// Subtracts the duration [time] from this Date instance.
Date subtract(Time time) {
return new DateImplementation.fromEpoch(value - time.duration, timeZone);
}
// Returns a [Time] with the difference of [this] and [other].
Time difference(DateTime other) {
Time difference(Date other) {
return new TimeImplementation.duration(value - other.value);
}
@ -337,7 +335,7 @@ class DateTimeImplementation implements DateTime {
return 2008 + (recentYear - 2008) % 28;
}
static brokenDownDateTimeToMillisecondsSinceEpoch_(
static brokenDownDateToMillisecondsSinceEpoch_(
int years, int month, int day,
int hours, int minutes, int seconds, int milliseconds,
bool isUtc) {
@ -379,36 +377,36 @@ class DateTimeImplementation implements DateTime {
equivalentYear = years;
offsetInSeconds = 0;
}
int secondsSinceEpoch = brokenDownDateTimeToSecondsSinceEpoch_(
int secondsSinceEpoch = brokenDownDateToSecondsSinceEpoch_(
equivalentYear, month, day, hours, minutes, seconds, isUtc);
int adjustedSeconds = secondsSinceEpoch + offsetInSeconds;
return adjustedSeconds * Time.MS_PER_SECOND + milliseconds;
}
// Natives
static brokenDownDateTimeToSecondsSinceEpoch_(
static brokenDownDateToSecondsSinceEpoch_(
int years, int month, int day, int hours, int minutes, int seconds,
bool isUtc) native "DateTimeNatives_brokenDownToSecondsSinceEpoch";
bool isUtc) native "DateNatives_brokenDownToSecondsSinceEpoch";
static int getCurrentMs_() native "DateTimeNatives_currentTimeMillis";
static int getCurrentMs_() native "DateNatives_currentTimeMillis";
// TODO(floitsch): it would be more efficient if we didn't call the native
// function for every member, but cached the broken-down date.
static int getYear_(int secondsSinceEpoch, bool isUtc)
native "DateTimeNatives_getYear";
native "DateNatives_getYear";
static int getMonth_(int secondsSinceEpoch, bool isUtc)
native "DateTimeNatives_getMonth";
native "DateNatives_getMonth";
static int getDay_(int secondsSinceEpoch, bool isUtc)
native "DateTimeNatives_getDay";
native "DateNatives_getDay";
static int getHours_(int secondsSinceEpoch, bool isUtc)
native "DateTimeNatives_getHours";
native "DateNatives_getHours";
static int getMinutes_(int secondsSinceEpoch, bool isUtc)
native "DateTimeNatives_getMinutes";
native "DateNatives_getMinutes";
static int getSeconds_(int secondsSinceEpoch, bool isUtc)
native "DateTimeNatives_getSeconds";
native "DateNatives_getSeconds";
}

View file

@ -11,8 +11,8 @@
'arrays.dart',
'bool.dart',
'collections.dart',
'date_time.cc',
'date_time.dart',
'date.cc',
'date.dart',
'double.cc',
'double.dart',
'growable_array.dart',

View file

@ -12,28 +12,28 @@ class MultipleTimerTest {
static void testMultipleTimer() {
void timeoutHandler1(Timer timer) {
int endTime = (new DateTime.now()).value;
int endTime = (new Date.now()).value;
Expect.equals(true, (endTime - _startTime1) >= TIMEOUT1);
Expect.equals(true, _order[_message] == 0);
_message++;
}
void timeoutHandler2(Timer timer) {
int endTime = (new DateTime.now()).value;
int endTime = (new Date.now()).value;
Expect.equals(true, (endTime - _startTime2) >= TIMEOUT2);
Expect.equals(true, _order[_message] == 1);
_message++;
}
void timeoutHandler3(Timer timer) {
int endTime = (new DateTime.now()).value;
int endTime = (new Date.now()).value;
Expect.equals(true, (endTime - _startTime3) >= TIMEOUT3);
Expect.equals(true, _order[_message] == 2);
_message++;
}
void timeoutHandler4(Timer timer) {
int endTime = (new DateTime.now()).value;
int endTime = (new Date.now()).value;
Expect.equals(true, (endTime - _startTime4) >= TIMEOUT4);
Expect.equals(true, _order[_message] == 3);
_message++;
@ -46,13 +46,13 @@ class MultipleTimerTest {
_order[3] = 1;
_message = 0;
_startTime1 = (new DateTime.now()).value;
_startTime1 = (new Date.now()).value;
new Timer(timeoutHandler1, TIMEOUT1, false);
_startTime2 = (new DateTime.now()).value;
_startTime2 = (new Date.now()).value;
new Timer(timeoutHandler2, TIMEOUT2, false);
_startTime3 = (new DateTime.now()).value;
_startTime3 = (new Date.now()).value;
new Timer(timeoutHandler3, TIMEOUT3, false);
_startTime4 = (new DateTime.now()).value;
_startTime4 = (new Date.now()).value;
new Timer(timeoutHandler4, TIMEOUT4, false);
}

View file

@ -10,10 +10,10 @@ class TimerRepeatTest {
static void testRepeatTimer() {
void timeoutHandler(Timer timer) {
int endTime = (new DateTime.now()).value;
int endTime = (new Date.now()).value;
_iteration++;
if (_iteration < _ITERATIONS) {
_startTime = (new DateTime.now()).value;
_startTime = (new Date.now()).value;
} else {
Expect.equals(_iteration, _ITERATIONS);
timer.cancel();
@ -21,7 +21,7 @@ class TimerRepeatTest {
}
_iteration = 0;
_startTime = (new DateTime.now()).value;
_startTime = (new Date.now()).value;
timer = new Timer(timeoutHandler, _TIMEOUT, true);
}

View file

@ -11,19 +11,19 @@ class TimerTest {
static void testSimpleTimer() {
void timeoutHandler(Timer timer) {
int endTime = (new DateTime.now()).value;
int endTime = (new Date.now()).value;
Expect.equals(true, (endTime - _startTime) >= _timeout);
if (_iteration < _ITERATIONS) {
_iteration++;
_timeout = _timeout - _DECREASE;
_startTime = (new DateTime.now()).value;
_startTime = (new Date.now()).value;
new Timer(timeoutHandler, _timeout, false);
}
}
_iteration = 0;
_timeout = _STARTTIMEOUT;
_startTime = (new DateTime.now()).value;
_startTime = (new Date.now()).value;
new Timer(timeoutHandler, _timeout, false);
}

View file

@ -85,14 +85,14 @@ namespace dart {
V(MathNatives_random, 0) \
V(MathNatives_parseInt, 1) \
V(MathNatives_parseDouble, 1) \
V(DateTimeNatives_brokenDownToSecondsSinceEpoch, 7) \
V(DateTimeNatives_currentTimeMillis, 0) \
V(DateTimeNatives_getYear, 2) \
V(DateTimeNatives_getMonth, 2) \
V(DateTimeNatives_getDay, 2) \
V(DateTimeNatives_getHours, 2) \
V(DateTimeNatives_getMinutes, 2) \
V(DateTimeNatives_getSeconds, 2) \
V(DateNatives_brokenDownToSecondsSinceEpoch, 7) \
V(DateNatives_currentTimeMillis, 0) \
V(DateNatives_getYear, 2) \
V(DateNatives_getMonth, 2) \
V(DateNatives_getDay, 2) \
V(DateNatives_getHours, 2) \
V(DateNatives_getMinutes, 2) \
V(DateNatives_getSeconds, 2) \
V(AssertError_throwNew, 2) \
V(FallThroughError_throwNew, 1) \
V(Clock_now, 0) \

View file

@ -15,14 +15,14 @@ class Isolate;
// Interface to the underlying OS platform.
class OS {
public:
typedef struct BrokenDownDateTime {
typedef struct BrokenDownDate {
int year; // Offset by 1900. A value of 111 Represents the year 2011.
int month; // [0..11]
int day; // [1..31]
int hours;
int minutes;
int seconds;
} BrokenDownDateTime;
} BrokenDownDate;
// Takes the seconds since epoch (midnight, January 1, 1970 UTC) and breaks it
// down into date and time.
@ -32,13 +32,13 @@ class OS {
// Returns true if the conversion succeeds, false otherwise.
static bool BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool in_utc,
BrokenDownDateTime* result);
BrokenDownDate* result);
// Converts a broken down date into the seconds since epoch (midnight,
// January 1, 1970 UTC). Returns true if the conversion succeeds, false
// otherwise.
static bool BrokenDownToSecondsSinceEpoch(
const BrokenDownDateTime& broken_down, bool in_utc, time_t* result);
const BrokenDownDate& broken_down, bool in_utc, time_t* result);
// Returns the current time in milliseconds measured
// from midnight January 1, 1970 UTC.

View file

@ -18,7 +18,7 @@ namespace dart {
bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool in_utc,
BrokenDownDateTime* result) {
BrokenDownDate* result) {
struct tm tm_result;
struct tm* error_code;
if (in_utc) {
@ -40,7 +40,7 @@ bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool OS::BrokenDownToSecondsSinceEpoch(
const BrokenDownDateTime& broken_down, bool in_utc, time_t* result) {
const BrokenDownDate& broken_down, bool in_utc, time_t* result) {
struct tm tm_broken_down;
// mktime takes the years since 1900.
tm_broken_down.tm_year = broken_down.year;

View file

@ -19,7 +19,7 @@ namespace dart {
bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool in_utc,
BrokenDownDateTime* result) {
BrokenDownDate* result) {
struct tm tm_result;
struct tm* error_code;
if (in_utc) {
@ -41,7 +41,7 @@ bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool OS::BrokenDownToSecondsSinceEpoch(
const BrokenDownDateTime& broken_down, bool in_utc, time_t* result) {
const BrokenDownDate& broken_down, bool in_utc, time_t* result) {
struct tm tm_broken_down;
// mktime takes the years since 1900.
tm_broken_down.tm_year = broken_down.year;

View file

@ -11,7 +11,7 @@ namespace dart {
bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool in_utc,
BrokenDownDateTime* result) {
BrokenDownDate* result) {
struct tm tm_result;
errno_t error_code;
if (in_utc) {
@ -33,7 +33,7 @@ bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch,
bool OS::BrokenDownToSecondsSinceEpoch(
const BrokenDownDateTime& broken_down, bool in_utc, time_t* result) {
const BrokenDownDate& broken_down, bool in_utc, time_t* result) {
struct tm tm_broken_down;
// mktime takes the years since 1900.
tm_broken_down.tm_year = broken_down.year;

View file

@ -739,10 +739,10 @@ class BenchmarkBase {
static double measureFor(Function f, int timeMinimum) {
int time = 0;
int iter = 0;
DateTime start = new DateTime.now();
Date start = new Date.now();
while (time < timeMinimum) {
f();
time = (new DateTime.now().difference(start)).duration;
time = (new Date.now().difference(start)).duration;
iter++;
}
// Force double result by using a double constant.
@ -1111,12 +1111,12 @@ class PingPongGame {
}
void evaluateRound() {
int time = (new DateTime.now().difference(_start)).duration;
int time = (new Date.now().difference(_start)).duration;
if (!_warmedup && time < Benchmark1.WARMUP_TIME) {
startRound();
} else if (!_warmedup) {
_warmedup = true;
_start = new DateTime.now();
_start = new Date.now();
_iterations = 0;
startRound();
} else if (_warmedup && time < Benchmark1.RUN_TIME) {
@ -1140,7 +1140,7 @@ class PingPongGame {
evaluateRound();
}
});
_start = new DateTime.now();
_start = new Date.now();
startRound();
}
@ -1149,7 +1149,7 @@ class PingPongGame {
_ping.close();
}
DateTime _start;
Date _start;
SendPort _pong;
SendPort _pingPort;
ReceivePort _ping;

View file

@ -9,7 +9,6 @@ prefix co19
#
[ $arch == dartc && $mode == release ]
LangGuideTest/02_Language_Constructs/02_6_Functions/A04/t02: Fail # Bug 5391976
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t09: Fail # Bug 5392516
LibTest/core/Set/add/Set/add/A01/t05: Fail # Bug 5392511
LibTest/core/Set/addAll/Set/addAll/A01/t05: Fail # Bug 5392511
LibTest/core/Set/contains/Set/contains/A01/t04: Fail # Bug 5392511
@ -180,20 +179,30 @@ 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.
LibTest/core/DateTime/DateTime/DateTime/A01/t05: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime/DateTime/A01/t06: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime/DateTime/A01/t07: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime/DateTime/A01/t08: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t02: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t03: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t05: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t04: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t06: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t07: Fail # Bug 5371670.
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t08: Fail # Bug 5371670.
# The DateTime class has been renamed to Date
LibTest/core/DateTime/compareTo/DateTime/compareTo/A01/t01: Skip
LibTest/core/DateTime/compareTo/DateTime/compareTo/A01/t02: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t01: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t02: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t03: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t04: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t05: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t06: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t07: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t08: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t09: Skip
LibTest/core/DateTime/DateTime/DateTime/A02/t01: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t01: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t02: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t03: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t04: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t05: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t06: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t07: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t08: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t09: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t10: Skip
LibTest/core/Map/containsKey/Map/containsKey/A01/t03: Fail # Bug 5371670.
LibTest/core/Map/containsValue/Map/containsValue/A01/t02: Fail # Bug 5371670.
LibTest/core/Map/forEach/Map/forEach/A01/t03: Fail # Bug 5371670.
@ -301,10 +310,6 @@ LibTest/core/Date/day/Date/day/A01/t03: Fail
LibTest/core/Date/toString/Date/toString/A01/t01: 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/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t10: Fail
LibTest/core/DateTime/DateTime/DateTime/A01/t09: Fail
LibTest/core/DateTime/compareTo/DateTime/compareTo/A01/t02: Fail
LibTest/core/DoubleLinkedList/every/DoubleLinkedList/every/A01/t03: Fail
LibTest/core/DoubleLinkedList/every/DoubleLinkedList/every/A01/t05: Fail
LibTest/core/DoubleLinkedList/every/DoubleLinkedList/every/A01/t08: Fail

View file

@ -146,6 +146,30 @@ LibTest/core/Date/year/Date/year/A01/t02 : Skip
LangGuideTest/02_Language_Constructs/02_1_Class/02_1_Class_Construction/A08/t02: Skip
# The DateTime class has been renamed to Date
LibTest/core/DateTime/compareTo/DateTime/compareTo/A01/t01: Skip
LibTest/core/DateTime/compareTo/DateTime/compareTo/A01/t02: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t01: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t02: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t03: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t04: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t05: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t06: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t07: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t08: Skip
LibTest/core/DateTime/DateTime/DateTime/A01/t09: Skip
LibTest/core/DateTime/DateTime/DateTime/A02/t01: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t01: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t02: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t03: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t04: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t05: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t06: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t07: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t08: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t09: Skip
LibTest/core/DateTime/DateTime.withTimeZone/DateTime/DateTime.withTimeZone/A01/t10: Skip
# Following tests define a main with an argument, per new specification
# we do not pass any argument to main.
LangGuideTest/07_Overriding/A05/t01: Fail,Okay
@ -236,7 +260,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/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
LibTest/core/DoubleLinkedList/forEach/DoubleLinkedList/forEach/A01/t06: Skip
@ -301,7 +324,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/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
LibTest/core/DoubleLinkedList/forEach/DoubleLinkedList/forEach/A01/t03: Fail

View file

@ -24,10 +24,7 @@ class CoreRuntimeTypesTest {
testMapOperators();
testMapMethods();
testLiterals();
// TODO(ngeoffray): re-enable this test once static const fields
// in interfaces are correctly emitted (b/4336711).
// testDateMethods();
testDateMethods();
}
static assertEquals(a, b) {
@ -263,16 +260,13 @@ class CoreRuntimeTypesTest {
}
static testDateMethods() {
// TODO(jimhug): Switch to named constructors when available.
// Pushing this into Jan 2nd to make the year independent of timezone.
// TODO(jimhug): Pursue a better solution to TZ issues.
var msec = 115201000;
var d = new DateTime(msec);
assertEquals(d.getSeconds(), 1);
assertEquals(d.getYear(), 1970);
var d = new Date.fromEpoch(msec, const TimeZone.utc());
assertEquals(d.seconds, 1);
assertEquals(d.year, 1970);
d = new DateTime();
assertEquals(d.getYear() >= 2011, true);
d = new Date.now();
assertEquals(d.year >= 2011, true);
}
static testLiterals() {

View file

@ -2,15 +2,15 @@
// 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 test program for DateTime.
// Dart test program for Date.
class DateTimeTest {
class DateTest {
// Tests if the time moves eventually forward.
static void testNow() {
var t1 = new DateTime.now();
var t1 = new Date.now();
bool timeMovedForward = false;
for (int i = 0; i < 1000000; i++) {
var t2 = new DateTime.now();
var t2 = new Date.now();
if (t1.value < t2.value) {
timeMovedForward = true;
break;
@ -20,15 +20,14 @@ class DateTimeTest {
}
static void testValue() {
var dt1 = new DateTime.now();
var dt1 = new Date.now();
var value = dt1.value;
var dt2 = new DateTime.fromEpoch(value, new TimeZone.local());
var dt2 = new Date.fromEpoch(value, new TimeZone.local());
Expect.equals(value, dt2.value);
}
static void testFarAwayDates() {
DateTime dt =
new DateTime.fromEpoch(1000000000000001, const TimeZone.utc());
Date dt = new Date.fromEpoch(1000000000000001, const TimeZone.utc());
Expect.equals(33658, dt.year);
Expect.equals(9, dt.month);
Expect.equals(27, dt.day);
@ -36,7 +35,7 @@ class DateTimeTest {
Expect.equals(46, dt.minutes);
Expect.equals(40, dt.seconds);
Expect.equals(1, dt.milliseconds);
dt = new DateTime.fromEpoch(-1000000000000001, const TimeZone.utc());
dt = new Date.fromEpoch(-1000000000000001, const TimeZone.utc());
Expect.equals(-29719, dt.year);
Expect.equals(4, dt.month);
Expect.equals(5, dt.day);
@ -45,7 +44,7 @@ class DateTimeTest {
Expect.equals(19, dt.seconds);
Expect.equals(999, dt.milliseconds);
// Same with local zone.
dt = new DateTime.fromEpoch(1000000000000001, new TimeZone.local());
dt = new Date.fromEpoch(1000000000000001, new TimeZone.local());
Expect.equals(33658, dt.year);
Expect.equals(9, dt.month);
Expect.equals(true, dt.day == 27 || dt.day == 26);
@ -55,7 +54,7 @@ class DateTimeTest {
Expect.equals(true, dt.minutes % 15 == 46 % 15);
Expect.equals(40, dt.seconds);
Expect.equals(1, dt.milliseconds);
dt = new DateTime.fromEpoch(-1000000000000001, new TimeZone.local());
dt = new Date.fromEpoch(-1000000000000001, new TimeZone.local());
Expect.equals(-29719, dt.year);
Expect.equals(4, dt.month);
Expect.equals(true, 5 == dt.day || 6 == dt.day);
@ -71,7 +70,7 @@ class DateTimeTest {
// All hardcoded values come from V8. This means that the values are not
// necessarily correct (see limitations of Date object in
// EcmaScript 15.9.1 and in particular 15.9.1.8/9).
DateTime dt = new DateTime.fromEpoch(-31485600000, const TimeZone.utc());
Date dt = new Date.fromEpoch(-31485600000, const TimeZone.utc());
Expect.equals(1969, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -79,7 +78,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-63108000000, const TimeZone.utc());
dt = new Date.fromEpoch(-63108000000, const TimeZone.utc());
Expect.equals(1968, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -87,7 +86,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-94644000000, const TimeZone.utc());
dt = new Date.fromEpoch(-94644000000, const TimeZone.utc());
Expect.equals(1967, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -95,7 +94,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-126180000000, const TimeZone.utc());
dt = new Date.fromEpoch(-126180000000, const TimeZone.utc());
Expect.equals(1966, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -103,7 +102,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-157716000000, const TimeZone.utc());
dt = new Date.fromEpoch(-157716000000, const TimeZone.utc());
Expect.equals(1965, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -111,7 +110,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-2177402400000, const TimeZone.utc());
dt = new Date.fromEpoch(-2177402400000, const TimeZone.utc());
Expect.equals(1901, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -119,7 +118,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-5333076000000, const TimeZone.utc());
dt = new Date.fromEpoch(-5333076000000, const TimeZone.utc());
Expect.equals(1801, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -127,7 +126,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-8520285600000, const TimeZone.utc());
dt = new Date.fromEpoch(-8520285600000, const TimeZone.utc());
Expect.equals(1700, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -135,7 +134,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-14831719200000, const TimeZone.utc());
dt = new Date.fromEpoch(-14831719200000, const TimeZone.utc());
Expect.equals(1500, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -143,7 +142,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-59011408800000, const TimeZone.utc());
dt = new Date.fromEpoch(-59011408800000, const TimeZone.utc());
Expect.equals(100, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -151,7 +150,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-62011408800000, const TimeZone.utc());
dt = new Date.fromEpoch(-62011408800000, const TimeZone.utc());
Expect.equals(4, dt.year);
Expect.equals(12, dt.month);
Expect.equals(8, dt.day);
@ -159,7 +158,7 @@ class DateTimeTest {
Expect.equals(40, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(0, dt.milliseconds);
dt = new DateTime.fromEpoch(-64011408800000, const TimeZone.utc());
dt = new Date.fromEpoch(-64011408800000, const TimeZone.utc());
Expect.equals(-59, dt.year);
Expect.equals(7, dt.month);
Expect.equals(24, dt.day);
@ -168,8 +167,7 @@ class DateTimeTest {
Expect.equals(40, dt.seconds);
Expect.equals(0, dt.milliseconds);
final int SECONDS_YEAR_2035 = 2051222400;
dt = new DateTime.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1,
const TimeZone.utc());
dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1, const TimeZone.utc());
Expect.equals(2035, dt.year);
Expect.equals(1, dt.month);
Expect.equals(1, dt.day);
@ -177,8 +175,7 @@ class DateTimeTest {
Expect.equals(0, dt.minutes);
Expect.equals(0, dt.seconds);
Expect.equals(1, dt.milliseconds);
dt = new DateTime.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1,
const TimeZone.utc());
dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1, const TimeZone.utc());
Expect.equals(2034, dt.year);
Expect.equals(12, dt.month);
Expect.equals(31, dt.day);
@ -186,36 +183,33 @@ class DateTimeTest {
Expect.equals(59, dt.minutes);
Expect.equals(59, dt.seconds);
Expect.equals(999, dt.milliseconds);
dt = new DateTime.withTimeZone(2035, 1, 1, 0, 0, 0, 1,
const TimeZone.utc());
dt = new Date.withTimeZone(2035, 1, 1, 0, 0, 0, 1, const TimeZone.utc());
Expect.equals(SECONDS_YEAR_2035 * 1000 + 1, dt.value);
dt = new DateTime.withTimeZone(2034, 12, 31, 23, 59, 59, 999,
const TimeZone.utc());
dt = new Date.withTimeZone(2034, 12, 31, 23, 59, 59, 999,
const TimeZone.utc());
Expect.equals(SECONDS_YEAR_2035 * 1000 - 1, dt.value);
dt = new DateTime.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1,
new TimeZone.local());
dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 + 1, new TimeZone.local());
Expect.equals(true, (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
(2034 == dt.year && 12 == dt.month && 31 == dt.day));
Expect.equals(0, dt.seconds);
Expect.equals(1, dt.milliseconds);
DateTime dt2 = new DateTime.withTimeZone(
Date dt2 = new Date.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());
dt = new Date.fromEpoch(SECONDS_YEAR_2035 * 1000 - 1, new TimeZone.local());
Expect.equals(true, (2035 == dt.year && 1 == dt.month && 1 == dt.day) ||
(2034 == dt.year && 12 == dt.month && 31 == dt.day));
Expect.equals(59, dt.seconds);
Expect.equals(999, dt.milliseconds);
dt2 = new DateTime.withTimeZone(
dt2 = new Date.withTimeZone(
dt.year, dt.month, dt.day, dt.hours, dt.minutes, dt.seconds,
dt.milliseconds, new TimeZone.local());
Expect.equals(dt.value, dt2.value);
}
static void testUTCGetters() {
var dt = new DateTime.fromEpoch(1305140315000, const TimeZone.utc());
var dt = new Date.fromEpoch(1305140315000, const TimeZone.utc());
Expect.equals(2011, dt.year);
Expect.equals(5, dt.month);
Expect.equals(11, dt.day);
@ -225,7 +219,7 @@ class DateTimeTest {
Expect.equals(0, dt.milliseconds);
Expect.equals(true, const TimeZone.utc() == dt.timeZone);
Expect.equals(1305140315000, dt.value);
dt = new DateTime.fromEpoch(-9999999, const TimeZone.utc());
dt = new Date.fromEpoch(-9999999, const TimeZone.utc());
Expect.equals(1969, dt.year);
Expect.equals(12, dt.month);
Expect.equals(31, dt.day);
@ -236,12 +230,11 @@ class DateTimeTest {
}
static void testLocalGetters() {
var dt1 = new DateTime.fromEpoch(1305140315000, new TimeZone.local());
var dt2 =
new DateTime.withTimeZone(dt1.year, dt1.month, dt1.day,
dt1.hours, dt1.minutes, dt1.seconds,
dt1.milliseconds,
const TimeZone.utc());
var dt1 = new Date.fromEpoch(1305140315000, new TimeZone.local());
var dt2 = new Date.withTimeZone(dt1.year, dt1.month, dt1.day,
dt1.hours, dt1.minutes, dt1.seconds,
dt1.milliseconds,
const TimeZone.utc());
Time zoneOffset = dt1.difference(dt2);
Expect.equals(true, zoneOffset.days == 0);
Expect.equals(true, zoneOffset.hours.abs() <= 12);
@ -259,38 +252,38 @@ class DateTimeTest {
}
static void testConstructors() {
var dt1 = new DateTime.fromEpoch(1305140315000, new TimeZone.local());
var dt3 = new DateTime(dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
dt1.seconds, dt1.milliseconds);
var dt1 = new Date.fromEpoch(1305140315000, new TimeZone.local());
var dt3 = new Date(dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
dt1.seconds, dt1.milliseconds);
Expect.equals(dt1.value, dt3.value);
Expect.equals(true, dt1 == dt3);
dt3 = new DateTime.withTimeZone(
dt3 = new Date.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,
const TimeZone.utc());
dt3 = new Date.withTimeZone(2011, 5, 11, 18, 58, 35, 0,
const TimeZone.utc());
Expect.equals(dt1.value, dt3.value);
Expect.equals(false, dt1 == dt3);
var dt2 = dt1.changeTimeZone(new TimeZone.local());
dt3 = new DateTime.withTimeZone(2011, 5, dt1.day,
dt1.hours, dt1.minutes, 35, 0,
new TimeZone.local());
dt3 = new Date.withTimeZone(2011, 5, dt1.day,
dt1.hours, dt1.minutes, 35, 0,
new TimeZone.local());
Expect.equals(dt2.value, dt3.value);
Expect.equals(true, dt2 == dt3);
dt1 = new DateTime.fromEpoch(-9999999, const TimeZone.utc());
dt3 = new DateTime.withTimeZone(
dt1 = new Date.fromEpoch(-9999999, const TimeZone.utc());
dt3 = new Date.withTimeZone(
dt1.year, dt1.month, dt1.day, dt1.hours, dt1.minutes,
dt1.seconds, dt1.milliseconds, const TimeZone.utc());
Expect.equals(dt1.value, dt3.value);
}
static void testChangeTimeZone() {
var dt1 = new DateTime.fromEpoch(1305140315000, new TimeZone.local());
var dt1 = new Date.fromEpoch(1305140315000, new TimeZone.local());
var dt2 = dt1.changeTimeZone(const TimeZone.utc());
Expect.equals(dt1.value, dt2.value);
var dt3 = new DateTime.fromEpoch(1305140315000, const TimeZone.utc());
var dt3 = new Date.fromEpoch(1305140315000, const TimeZone.utc());
Expect.equals(dt1.value, dt3.value);
Expect.equals(dt2.year, dt3.year);
Expect.equals(dt2.month, dt3.month);
@ -310,7 +303,7 @@ class DateTimeTest {
}
static void testSubAdd() {
var dt1 = new DateTime.fromEpoch(1305140315000, const TimeZone.utc());
var dt1 = new Date.fromEpoch(1305140315000, const TimeZone.utc());
var dt2 = dt1.add(const Time.duration(3 * Time.MS_PER_SECOND + 5));
Expect.equals(dt1.year, dt2.year);
Expect.equals(dt1.month, dt2.month);
@ -325,11 +318,11 @@ class DateTimeTest {
}
static void testDateStrings() {
// TODO(floitsch): Clean up the DateTime API that deals with strings.
var dt1 = new DateTime.fromString("2011-05-11 18:58:35Z");
// TODO(floitsch): Clean up the Date API that deals with strings.
var dt1 = new Date.fromString("2011-05-11 18:58:35Z");
Expect.equals(1305140315000, dt1.value);
var str = dt1.toString();
var dt2 = new DateTime.fromString(str);
var dt2 = new Date.fromString(str);
Expect.equals(true, dt1 == dt2);
var dt3 = dt1.changeTimeZone(const TimeZone.utc());
str = dt3.toString();
@ -351,5 +344,5 @@ class DateTimeTest {
}
main() {
DateTimeTest.testMain();
DateTest.testMain();
}

View file

@ -4,7 +4,7 @@
class Issue4157508Test {
Issue4157508Test(var v) {
var d = new DateTime.fromEpoch(v, const TimeZone.utc());
var d = new Date.fromEpoch(v, const TimeZone.utc());
}
static void testMain() {