aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKevin Wells2013-05-07 22:58:05 +0100
committerPete Bacon Darwin2013-05-07 22:59:46 +0100
commit4f2e36068502f18814fee0abd26951124881f951 (patch)
tree7d15c61192697ac787cf575288eefbfc1d9b5cb0 /test
parent4622af3f075204e2d5ab33d5bd002074f2d940c9 (diff)
downloadangular.js-4f2e36068502f18814fee0abd26951124881f951.tar.bz2
fix(date): correctly format dates with more than 3 sub-second digits
This date {{2003-09-10T13:02:03.123456Z | date: yyyy-mm-dd ss} is now treated as having 123.45ms. Previously it had 123456ms so 123 seconds were added to the formatted date. Use local date in unit tests so they work in any time zone
Diffstat (limited to 'test')
-rw-r--r--test/ng/filter/filtersSpec.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/test/ng/filter/filtersSpec.js b/test/ng/filter/filtersSpec.js
index 2ed99cf1..eb98c355 100644
--- a/test/ng/filter/filtersSpec.js
+++ b/test/ng/filter/filtersSpec.js
@@ -300,21 +300,23 @@ describe('filters', function() {
it('should support various iso8061 date strings with timezone as input', function() {
var format = 'yyyy-MM-dd ss';
+ var localDay = new Date(Date.UTC(2003, 9, 10, 13, 2, 3, 0)).getDate();
+
//full ISO8061
- expect(date('2003-09-10T13:02:03.000Z', format)).toEqual('2003-09-10 03');
+ expect(date('2003-09-10T13:02:03.000Z', format)).toEqual('2003-09-' + localDay + ' 03');
- expect(date('2003-09-10T13:02:03.000+00:00', format)).toEqual('2003-09-10 03');
+ expect(date('2003-09-10T13:02:03.000+00:00', format)).toEqual('2003-09-' + localDay + ' 03');
- expect(date('20030910T033203-0930', format)).toEqual('2003-09-10 03');
+ expect(date('20030910T033203-0930', format)).toEqual('2003-09-' + localDay + ' 03');
//no millis
- expect(date('2003-09-10T13:02:03Z', format)).toEqual('2003-09-10 03');
+ expect(date('2003-09-10T13:02:03Z', format)).toEqual('2003-09-' + localDay + ' 03');
//no seconds
- expect(date('2003-09-10T13:02Z', format)).toEqual('2003-09-10 00');
+ expect(date('2003-09-10T13:02Z', format)).toEqual('2003-09-' + localDay + ' 00');
//no minutes
- expect(date('2003-09-10T13Z', format)).toEqual('2003-09-10 00');
+ expect(date('2003-09-10T13Z', format)).toEqual('2003-09-' + localDay + ' 00');
});
@@ -331,16 +333,18 @@ describe('filters', function() {
});
it('should support different degrees of subsecond precision', function () {
- var format = 'yyyy-MM-dd';
-
- expect(date('2003-09-10T13:02:03.12345678Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.1234567Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.123456Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.12345Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.1234Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.123Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.12Z', format)).toEqual('2003-09-10');
- expect(date('2003-09-10T13:02:03.1Z', format)).toEqual('2003-09-10');
+ var format = 'yyyy-MM-dd ss';
+
+ var localDay = new Date(Date.UTC(2003, 9-1, 10, 13, 2, 3, 123)).getDate();
+
+ expect(date('2003-09-10T13:02:03.12345678Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.1234567Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.123456Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.12345Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.1234Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.123Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.12Z', format)).toEqual('2003-09-' + localDay + ' 03');
+ expect(date('2003-09-10T13:02:03.1Z', format)).toEqual('2003-09-' + localDay + ' 03');
});
});
});