Skip to content

Commit

Permalink
Merge pull request sproutcore#622 from workmanw/datetime
Browse files Browse the repository at this point in the history
SC.DateTime should invoke class methods using 'this' instead of 'SC.DateTime'.
  • Loading branch information
Public Keating committed Dec 2, 2011
2 parents 21d3543 + 72d8cd3 commit 9527030
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frameworks/datetime/frameworks/core/system/datetime.js
Expand Up @@ -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;
},

/**
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions frameworks/datetime/frameworks/core/tests/system/datetime.js
Expand Up @@ -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.');
});

0 comments on commit 9527030

Please sign in to comment.