mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-29 05:15:38 +08:00
Revert "added support for treating numbers as date in miliseconds"
This reverts commit 1391f19fb4.
This commit is contained in:
@@ -75,14 +75,8 @@ var DATE_FORMATS = {
|
|||||||
var DATE_FORMATS_SPLIT = /([^yMdHhmsaZ]*)(y+|M+|d+|H+|h+|m+|s+|a|Z)(.*)/;
|
var DATE_FORMATS_SPLIT = /([^yMdHhmsaZ]*)(y+|M+|d+|H+|h+|m+|s+|a|Z)(.*)/;
|
||||||
|
|
||||||
angularFilter.date = function(date, format) {
|
angularFilter.date = function(date, format) {
|
||||||
var text, fn;
|
if (!(date instanceof Date)) return date;
|
||||||
if (!date) return date;
|
var text = date.toLocaleDateString(), fn;
|
||||||
if (!(date instanceof Date)) {
|
|
||||||
text = parseInt(date, 10);
|
|
||||||
date = new Date();
|
|
||||||
date.setTime(text);
|
|
||||||
}
|
|
||||||
text = date.toLocaleDateString();
|
|
||||||
if (format && isString(format)) {
|
if (format && isString(format)) {
|
||||||
text = '';
|
text = '';
|
||||||
var parts = [];
|
var parts = [];
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ describe('filter', function(){
|
|||||||
it('should ignore falsy inputs', function() {
|
it('should ignore falsy inputs', function() {
|
||||||
expect(filter.date(null)).toEqual(null);
|
expect(filter.date(null)).toEqual(null);
|
||||||
expect(filter.date('')).toEqual('');
|
expect(filter.date('')).toEqual('');
|
||||||
|
expect(filter.date(123)).toEqual(123);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do basic filter', function() {
|
it('should do basic filter', function() {
|
||||||
@@ -122,9 +123,6 @@ describe('filter', function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should accept miliseconds as date', function(){
|
|
||||||
expect(filter.date("123", "yyyy")).toEqual('1969');
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user