Fixed date-parsing logic so that it works on oldIE. Issue #323.
This commit is contained in:
@@ -134,14 +134,14 @@ my.Timeline = Backbone.View.extend({
|
|||||||
if (!date) {
|
if (!date) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var out = date.trim();
|
var out = $.trim(date);
|
||||||
out = out.replace(/(\d)th/g, '$1');
|
out = out.replace(/(\d)th/g, '$1');
|
||||||
out = out.replace(/(\d)st/g, '$1');
|
out = out.replace(/(\d)st/g, '$1');
|
||||||
out = out.trim() ? moment(out) : null;
|
out = $.trim(out) ? moment(out) : null;
|
||||||
if (out.toDate() == 'Invalid Date') {
|
if (out && out.isValid()) {
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return out.toDate();
|
return out.toDate();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ test('extract dates and timelineJSON', function () {
|
|||||||
'headline': '',
|
'headline': '',
|
||||||
'date': [
|
'date': [
|
||||||
{
|
{
|
||||||
'startDate': new Date('2012-03-20'),
|
'startDate': moment('2012-03-20').toDate(),
|
||||||
'endDate': null,
|
'endDate': null,
|
||||||
'headline': '1',
|
'headline': '1',
|
||||||
'text': '<div class="recline-record-summary"><div class="Date"><strong>Date</strong>: 2012-03-20</div><div class="title"><strong>title</strong>: 1</div></div>'
|
'text': '<div class="recline-record-summary"><div class="Date"><strong>Date</strong>: 2012-03-20</div><div class="title"><strong>title</strong>: 1</div></div>'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'startDate': new Date('2012-03-25'),
|
'startDate': moment('2012-03-25').toDate(),
|
||||||
'endDate': null,
|
'endDate': null,
|
||||||
'headline': '2',
|
'headline': '2',
|
||||||
'text': '<div class="recline-record-summary"><div class="Date"><strong>Date</strong>: 2012-03-25</div><div class="title"><strong>title</strong>: 2</div></div>'
|
'text': '<div class="recline-record-summary"><div class="Date"><strong>Date</strong>: 2012-03-25</div><div class="title"><strong>title</strong>: 2</div></div>'
|
||||||
|
|||||||
Reference in New Issue
Block a user