From d62b0ff12fc83e18d451d1234e7faed2b7f217a6 Mon Sep 17 00:00:00 2001 From: Wesley Workman Date: Wed, 5 Oct 2011 11:39:59 -0400 Subject: [PATCH 1/2] Merge branch 'master', remote-tracking branch 'upstream/master' From 72d8cd3819e509e3821dd65cbb02c6d41c18aba5 Mon Sep 17 00:00:00 2001 From: Wesley Workman Date: Fri, 4 Nov 2011 15:06:23 -0400 Subject: [PATCH 2/2] Modified SC.DateTime to invoke class methods using 'this' instead of 'SC.DateTime'. This allows SC.DateTime to be extended for use in other apps and frameworks. Additionally added unit tests to verify it. --- frameworks/datetime/frameworks/core/system/datetime.js | 4 ++-- .../datetime/frameworks/core/tests/system/datetime.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frameworks/datetime/frameworks/core/system/datetime.js b/frameworks/datetime/frameworks/core/system/datetime.js index 6618d8b322..819ddaf9c4 100644 --- a/frameworks/datetime/frameworks/core/system/datetime.js +++ b/frameworks/datetime/frameworks/core/system/datetime.js @@ -384,7 +384,7 @@ SC.DateTime = SC.Object.extend(SC.Freezable, SC.Copyable, @returns {Boolean} */ isEqual: function(aDateTime) { - return SC.DateTime.compare(this, aDateTime) === 0; + return this.constructor.compare(this, aDateTime) === 0; }, /** @@ -982,7 +982,7 @@ SC.DateTime.mixin(SC.Comparable, delete opts.meridian; } - d = SC.DateTime.create(opts); + d = this.create(opts); if (!SC.none(check.dayOfWeek) && d.get('dayOfWeek') !== check.dayOfWeek) { return null; diff --git a/frameworks/datetime/frameworks/core/tests/system/datetime.js b/frameworks/datetime/frameworks/core/tests/system/datetime.js index 22b113b520..94bd3c17b9 100644 --- a/frameworks/datetime/frameworks/core/tests/system/datetime.js +++ b/frameworks/datetime/frameworks/core/tests/system/datetime.js @@ -394,3 +394,11 @@ test('timezones', function() { timeShouldBeEqualToHash(dt.toTimezone(-120), {year: o.year, month: o.month, day: o.day, hour: 6, minute: o.minute, second: o.second, millisecond: o.millisecond, timezone: -120 }); timeShouldBeEqualToHash(dt.toTimezone(-330), {year: o.year, month: o.month, day: o.day, hour: 9, minute: 30, second: o.second, millisecond: o.millisecond, timezone: -330 }); }); + +test('extend', function() { + var dateTimeExt = SC.DateTime.extend(); + + // Should parse and produce a date object that is an instance of 'dateTimeExt' + var parsedDateTimeExt = dateTimeExt.parse('2011-10-15T21:30:00Z'); + ok(SC.instanceOf(parsedDateTimeExt, dateTimeExt), 'Correctly produced an instance of the extended type.'); +});