Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(timezone): correct timezone date filter for 1/2 hour offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujeet Pillai authored and mhevery committed Mar 15, 2013
1 parent 79049b9 commit 1c1cd4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ function timeZoneGetter(date) {
var zone = -1 * date.getTimezoneOffset();
var paddedZone = (zone >= 0) ? "+" : "";

paddedZone += padNumber(zone / 60, 2) + padNumber(Math.abs(zone % 60), 2);
paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) +
padNumber(Math.abs(zone % 60), 2);

return paddedZone;
}
Expand Down
8 changes: 8 additions & 0 deletions test/ng/filter/filtersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ describe('filters', function() {
var utc = new angular.mock.TzDate( 0, '2010-09-03T12:05:08.000Z');
var eastOfUTC = new angular.mock.TzDate(-5, '2010-09-03T12:05:08.000Z');
var westOfUTC = new angular.mock.TzDate(+5, '2010-09-03T12:05:08.000Z');
var eastOfUTCPartial = new angular.mock.TzDate(-5.5, '2010-09-03T12:05:08.000Z');
var westOfUTCPartial = new angular.mock.TzDate(+5.5, '2010-09-03T12:05:08.000Z');

expect(date(utc, "yyyy-MM-ddTHH:mm:ssZ")).
toEqual('2010-09-03T12:05:08+0000')
Expand All @@ -245,6 +247,12 @@ describe('filters', function() {

expect(date(westOfUTC, "yyyy-MM-ddTHH:mm:ssZ")).
toEqual('2010-09-03T07:05:08-0500')

expect(date(eastOfUTCPartial, "yyyy-MM-ddTHH:mm:ssZ")).
toEqual('2010-09-03T17:35:08+0530')

expect(date(westOfUTCPartial, "yyyy-MM-ddTHH:mm:ssZ")).
toEqual('2010-09-03T06:35:08-0530')
});

it('should treat single quoted strings as string literals', function() {
Expand Down

0 comments on commit 1c1cd4f

Please sign in to comment.