Skip to content
Permalink
Browse files

fix(orderBy): compare timestamps when sorting date objects

Fixes #10512
Closes #10516
  • Loading branch information
pkozlowski-opensource committed Dec 18, 2014
1 parent 56a7abd commit 661f6d9ecf1459ce3b2794c3cde373e17ae83972
Showing with 14 additions and 4 deletions.
  1. +4 −4 src/ng/filter/orderBy.js
  2. +10 −0 test/ng/filter/orderBySpec.js
@@ -172,14 +172,14 @@ function orderByFilter($parse) {

function objectToString(value) {
if (value === null) return 'null';
if (typeof value.toString === 'function') {
value = value.toString();
if (isPrimitive(value)) return value;
}
if (typeof value.valueOf === 'function') {
value = value.valueOf();
if (isPrimitive(value)) return value;
}
if (typeof value.toString === 'function') {
value = value.toString();
if (isPrimitive(value)) return value;
}
return '';
}

@@ -79,6 +79,16 @@ describe('Filter: orderBy', function() {
{ a:new Date('01/01/2014'), b:3 }]);
});

it('should compare timestamps when sorting dates', function() {
expect(orderBy([
new Date('01/01/2015'),
new Date('01/01/2014')
])).toEqualData([
new Date('01/01/2014'),
new Date('01/01/2015')
]);
});


it('should use function', function() {
expect(

0 comments on commit 661f6d9

Please sign in to comment.
You can’t perform that action at this time.