Skip to content

Commit

Permalink
Handle sources dates separated by 'und'
Browse files Browse the repository at this point in the history
  • Loading branch information
kremio committed Nov 4, 2018
1 parent fd33e11 commit 90dccc3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
5 changes: 2 additions & 3 deletions lib/report.js
Expand Up @@ -157,16 +157,15 @@ const parseClassNames = (classNames) => {
const parseSources = (sources) => {
const sourcesArr = germanDays.removeThem( sources.replace('Quelle:',''), ',')
.replace(/(\(.+),(.+\))/, '$1%$2') //replace commas inside parens by %
.replace(/\sund\s/,',') //turn " und "s into commas
.replace(/\sund\s+([^0-9])/,',$1') //turn " und "s into commas
.split(',')
.map( (source) => source.trim() )
.map( (source) => {
let name = source
let publishedDate = null
let url = null

if( source.indexOf("vom") >= 0 ){
const {day, month, year} = parseDate( source.match(/vom(.*)$/)[1].trim().split('/').pop() )
const {day, month, year} = parseDate( source.match(/vom(.*)$/)[1].trim().split(/\/|und/).pop() )
publishedDate = new tc.DateTime( `${year}-${month.toString().padStart(2,'0')}-${day.toString().padStart(2,'0')}T00:00${TIMEZONE}` ).toIsoString()
name = name.replace(/vom(.*)$/,'').trim()
}
Expand Down
12 changes: 0 additions & 12 deletions special-cases.js
Expand Up @@ -71,17 +71,5 @@ module.exports = {
startDate: ( new Date('2014-01-31') ).toISOString(),
endDate: ( new Date('2014-02-02') ).toISOString(),
title: "Swoboda Aktivisten beim Münchener „Mini-Maidan“"
},
"https://muenchen-chronik.de/4-august-2018-auseinandersetzung-um-neonazistische-taetowierung/":{
sources: [
{
"name":"a.i.d.a.",
"publishedDate":null,
"url":null
},{
"name":"TZ",
"publishedDate":"2018-08-07T00:00:00.000+02:00",
"url":"http://www.tz.de"
}]
}
}

0 comments on commit 90dccc3

Please sign in to comment.