Permalink
Browse files
fix(orderBy): compare timestamps when sorting date objects
- Loading branch information
Showing
with
14 additions
and
4 deletions.
-
+4
−4
src/ng/filter/orderBy.js
-
+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( |
|
|
|