Skip to content

Commit

Permalink
Handle sources dates with year given using only 2 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
kremio committed Jun 14, 2019
1 parent 45f5146 commit baeb3ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/report.js
Expand Up @@ -83,7 +83,10 @@ module.exports = async ( url ) => {
.map((source) => {
const [name, dateDDMMYYYY] = source.split(', ')
if( dateDDMMYYYY ){
const [day, month, year] = dateDDMMYYYY.split('.').map((str) => str.trim())
let [day, month, year] = dateDDMMYYYY.split('.').map((str) => str.trim())
if(Number(year) < 2000){
year = 2000 + Number(year)
}
return {
name,
publishedDate: new tc.DateTime( `${year}-${month.padStart(2,'0')}-${day.padStart(2,'0')}T00:00${TIMEZONE}` ).toIsoString()
Expand Down

0 comments on commit baeb3ae

Please sign in to comment.