aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSujeet Pillai2013-03-14 17:19:13 +0530
committerMisko Hevery2013-03-14 22:16:54 -0700
commit1c1cd4fdf6b6d7511c7b8dc61b8042011dc54830 (patch)
treeca7f814ba9c3283811c1efb63bee7d39aae8fcfc
parent79049b9fee5690b8370c51e0fbb82d7a16b787fc (diff)
downloadangular.js-1c1cd4fdf6b6d7511c7b8dc61b8042011dc54830.tar.bz2
fix(timezone): correct timezone date filter for 1/2 hour offsets
-rw-r--r--src/ng/filter/filters.js3
-rw-r--r--test/ng/filter/filtersSpec.js8
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js
index 38861147..d4f09581 100644
--- a/src/ng/filter/filters.js
+++ b/src/ng/filter/filters.js
@@ -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;
}
diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js
index 071902a9..2ed99cf1 100644
--- a/test/ng/filter/filtersSpec.js
+++ b/test/ng/filter/filtersSpec.js
@@ -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')
@@ -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() {