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

Commit 1c1cd4f

Browse files
Sujeet Pillaimhevery
Sujeet Pillai
authored andcommitted
fix(timezone): correct timezone date filter for 1/2 hour offsets
1 parent 79049b9 commit 1c1cd4f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/ng/filter/filters.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ function timeZoneGetter(date) {
214214
var zone = -1 * date.getTimezoneOffset();
215215
var paddedZone = (zone >= 0) ? "+" : "";
216216

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

219220
return paddedZone;
220221
}

test/ng/filter/filtersSpec.js

+8
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ describe('filters', function() {
236236
var utc = new angular.mock.TzDate( 0, '2010-09-03T12:05:08.000Z');
237237
var eastOfUTC = new angular.mock.TzDate(-5, '2010-09-03T12:05:08.000Z');
238238
var westOfUTC = new angular.mock.TzDate(+5, '2010-09-03T12:05:08.000Z');
239+
var eastOfUTCPartial = new angular.mock.TzDate(-5.5, '2010-09-03T12:05:08.000Z');
240+
var westOfUTCPartial = new angular.mock.TzDate(+5.5, '2010-09-03T12:05:08.000Z');
239241

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

246248
expect(date(westOfUTC, "yyyy-MM-ddTHH:mm:ssZ")).
247249
toEqual('2010-09-03T07:05:08-0500')
250+
251+
expect(date(eastOfUTCPartial, "yyyy-MM-ddTHH:mm:ssZ")).
252+
toEqual('2010-09-03T17:35:08+0530')
253+
254+
expect(date(westOfUTCPartial, "yyyy-MM-ddTHH:mm:ssZ")).
255+
toEqual('2010-09-03T06:35:08-0530')
248256
});
249257

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

0 commit comments

Comments
 (0)