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