mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
fix(timezone): correct timezone date filter for 1/2 hour offsets
This commit is contained in:
parent
79049b9fee
commit
1c1cd4fdf6
2 changed files with 10 additions and 1 deletions
|
|
@ -214,7 +214,8 @@ function timeZoneGetter(date) {
|
||||||
var zone = -1 * date.getTimezoneOffset();
|
var zone = -1 * date.getTimezoneOffset();
|
||||||
var paddedZone = (zone >= 0) ? "+" : "";
|
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;
|
return paddedZone;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,8 @@ describe('filters', function() {
|
||||||
var utc = new angular.mock.TzDate( 0, '2010-09-03T12:05:08.000Z');
|
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 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 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")).
|
expect(date(utc, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||||
toEqual('2010-09-03T12:05:08+0000')
|
toEqual('2010-09-03T12:05:08+0000')
|
||||||
|
|
@ -245,6 +247,12 @@ describe('filters', function() {
|
||||||
|
|
||||||
expect(date(westOfUTC, "yyyy-MM-ddTHH:mm:ssZ")).
|
expect(date(westOfUTC, "yyyy-MM-ddTHH:mm:ssZ")).
|
||||||
toEqual('2010-09-03T07:05:08-0500')
|
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() {
|
it('should treat single quoted strings as string literals', function() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue