From 5c5430314ab08fd33f262fa930ddfd26a0c14963 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sun, 25 Feb 2018 17:46:18 +0100 Subject: [PATCH] fix date parsing +1 month --- api/tools/log-parse-tool.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/api/tools/log-parse-tool.js b/api/tools/log-parse-tool.js index ddb95a0..1f11138 100644 --- a/api/tools/log-parse-tool.js +++ b/api/tools/log-parse-tool.js @@ -64,13 +64,15 @@ const parseWarLog = (lineArray, war) => { const budg = line.split(WHITESPACE); if (line.includes('Startbudget')) { stats.war['budgetBlufor'] = transformMoneyString(budg[9]); - stats.war['budgetOpfor'] = transformMoneyString(budg[12].slice(0,-1)); + stats.war['budgetOpfor'] = transformMoneyString(budg[12].slice(0, -1)); + // this date needs to be assigned in first place !important - const dateString = budg[0].slice(0,-1).split('/'); - stats.war.date = new Date(dateString[0], dateString[1], dateString[2]) + const dateString = budg[0].slice(0, -1).split('/').map(s => parseInt(s)); + stats.war.date = new Date(dateString[0], dateString[1] - 1, dateString[2]); + } else if (line.includes('Endbudget')) { stats.war['endBudgetBlufor'] = transformMoneyString(budg[9].substr(1)); - stats.war['endBudgetOpfor'] = transformMoneyString(budg[12].slice(0,-1)); + stats.war['endBudgetOpfor'] = transformMoneyString(budg[12].slice(0, -1)); stats.war.endDate = getFullTimeDate(war.date, budg[5]); } else { stats.budget.push(getBudgetEntry(budg, war._id, war.date)); @@ -117,7 +119,7 @@ const parseWarLog = (lineArray, war) => { */ else if (line.includes('(Respawn)')) { const resp = line.split(WHITESPACE); - const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('- Kosten') -1); + const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('- Kosten') - 1); stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date)); } -- 2.25.1