Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.

Commit

Permalink
fix issue #37
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho committed Jul 27, 2012
1 parent e401a59 commit 48efd5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 7 additions & 0 deletions spec/date.spec.js
Expand Up @@ -218,4 +218,11 @@ describe('timezoneJS.Date', function () {
var dt = new timezoneJS.Date(1955, 9, 30, 0, 0, 0, 'America/New_York');
expect(dt.getTimezoneOffset()).toEqual(240);
});

it('should handle Pacific/Apia correctly', function () {
var dt = new timezoneJS.Date(2011, 11, 29, 23, 59, 59, 'Pacific/Apia');
dt.setTime(dt.getTime() + 1000);
expect(dt.toString()).toEqual('2011-12-31 00:00:00');
});

});
6 changes: 2 additions & 4 deletions src/date.js
Expand Up @@ -263,9 +263,7 @@
setSeconds: function (n) { this.setAttribute('seconds', n); },
setTime: function (n) {
if (isNaN(n)) { throw new Error('Units must be a number.'); }
var dt = new Date(0);
dt.setUTCMilliseconds(n - (this.getTimezoneOffset() * 60 * 1000));
this.setFromDateObjProxy(dt, true);
this.setFromTimeProxy(n, this.timezone);
},
setUTCDate: function (n) { this.setUTCAttribute('date', n); },
setUTCFullYear: function (n) { this.setUTCAttribute('year', n); },
Expand Down Expand Up @@ -482,7 +480,7 @@
mon = SHORT_MONTHS[z[4].substr(0, 3)];
dat = parseInt(z[5], 10) || 1;
}
var string = z[6] ? z[6] : '23:59:59';
var string = z[6] ? z[6] : '00:00:00';
t = parseTimeString(string);
return [yea, mon, dat, t[1], t[2], t[3]];
}
Expand Down

0 comments on commit 48efd5e

Please sign in to comment.