diff options
| author | Philip Roberts | 2013-01-30 10:50:34 +0100 |
|---|---|---|
| committer | Igor Minar | 2013-02-07 01:47:19 -0800 |
| commit | 8d34bf2feaa303ef286e3309ad766ff7d15f8b11 (patch) | |
| tree | 6879e83bff79b6a02a9a96ea4f04455513b79d47 /test | |
| parent | 8801e69dba5d5713bb25de7203a73e5b503694e0 (diff) | |
| download | angular.js-8d34bf2feaa303ef286e3309ad766ff7d15f8b11.tar.bz2 | |
fix(date): invert timezone sign and always display sign
This commit fixes #1261 and #1532. This covers
two separate issues:
- Positive timezones were being formatted without
a leading `+` resulting in a formatting string
like: "HH:MM:ssZ" giving "12:13:141000" instead
of "12:13:14+1000". Fixed by checking if timezone
is > 0 and adding a leading "+".
- Timezone output signs were inverted.
mock.TzDate expects the timezone _offset_ as it's
first argument, _not_ the timezone. This means
that a mock.TzDate with a positive offset should
result in a date string with a negative timezone,
and vice-versa.
Closes #1261, #1532
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/filter/filtersSpec.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js index cbb41841..f7e775ee 100644 --- a/test/ng/filter/filtersSpec.js +++ b/test/ng/filter/filtersSpec.js @@ -193,13 +193,13 @@ describe('filters', function() { toEqual('10-09-03 07:05:08'); expect(date(midnight, "yyyy-M-d h=H:m:saZ")). - toEqual('2010-9-3 12=0:5:8AM0500'); + toEqual('2010-9-3 12=0:5:8AM-0500'); expect(date(midnight, "yyyy-MM-dd hh=HH:mm:ssaZ")). - toEqual('2010-09-03 12=00:05:08AM0500'); + toEqual('2010-09-03 12=00:05:08AM-0500'); expect(date(noon, "yyyy-MM-dd hh=HH:mm:ssaZ")). - toEqual('2010-09-03 12=12:05:08PM0500'); + toEqual('2010-09-03 12=12:05:08PM-0500'); expect(date(noon, "EEE, MMM d, yyyy")). toEqual('Fri, Sep 3, 2010'); @@ -211,14 +211,30 @@ describe('filters', function() { toEqual('September 03, 1'); }); + it('should format timezones correctly (as per ISO_8601)', function() { + //Note: TzDate's first argument is offset, _not_ timezone. + 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'); + + expect(date(utc, "yyyy-MM-ddTHH:mm:ssZ")). + toEqual('2010-09-03T12:05:08+0000') + + expect(date(eastOfUTC, "yyyy-MM-ddTHH:mm:ssZ")). + toEqual('2010-09-03T17:05:08+0500') + + expect(date(westOfUTC, "yyyy-MM-ddTHH:mm:ssZ")). + toEqual('2010-09-03T07:05:08-0500') + }); + it('should treat single quoted strings as string literals', function() { expect(date(midnight, "yyyy'de' 'a'x'dd' 'adZ' h=H:m:saZ")). - toEqual('2010de axdd adZ 12=0:5:8AM0500'); + toEqual('2010de axdd adZ 12=0:5:8AM-0500'); }); it('should treat a sequence of two single quotes as a literal single quote', function() { expect(date(midnight, "yyyy'de' 'a''dd' 'adZ' h=H:m:saZ")). - toEqual("2010de a'dd adZ 12=0:5:8AM0500"); + toEqual("2010de a'dd adZ 12=0:5:8AM-0500"); }); it('should accept default formats', function() { |
