[#152,timeline][xs]: handle null or undefined dates properly.

This commit is contained in:
Rufus Pollock 2012-06-10 14:23:03 +01:00
parent 6a746420c6
commit d2ce46cc42
2 changed files with 5 additions and 1 deletions

View File

@ -103,6 +103,9 @@ my.Timeline = Backbone.View.extend({
},
_parseDate: function(date) {
if (!date) {
return null;
}
var out = date.trim();
out = out.replace(/(\d)th/g, '$1');
out = out.replace(/(\d)st/g, '$1');

View File

@ -59,7 +59,8 @@ test('_parseDate', function () {
[ 'August 1st 1914', '1914-08-01T00:00:00.000Z' ],
[ '1914-08-01', '1914-08-01T00:00:00.000Z' ],
[ '1914-08-01T08:00', '1914-08-01T08:00:00.000Z' ],
[ 'afdaf afdaf', null ]
[ 'afdaf afdaf', null ],
[ null, null ]
];
_.each(testData, function(item) {
var out = view._parseDate(item[0]);