--- /dev/null
+const fs = require('fs')
+
+function badDate(line) {
+ // -20.00;2016/8/27;;old stadio
+ const tokens = line.split(';')
+ const date = tokens[1]
+ const dateTokens = date.split('/')
+ return dateTokens[2].length !== 4
+}
+
+function fixDate(line) {
+ // -20.00;2016/8/27;;old stadio
+ const tokens = line.split(';')
+ const date = tokens[1]
+ const dateTokens = date.split('/')
+ const dateOk = dateTokens[2].padStart(2, '0') + '/' + dateTokens[1].padStart(2, '0') + '/' + dateTokens[0].padStart(4, '0')
+ const output = tokens[0] + ';' + dateOk + ';' + tokens[2] + ';' + tokens[3]
+ return output
+}
+
+async function main() {
+ const inputFile = process.argv.slice(2)[0]
+ fs.readFile(inputFile, 'utf-8', (err, data) => {
+ if(err){
+ console.error(err)
+ return err
+ }
+ const lines = data.split(/\r?\n/)
+ for(line of lines) {
+ if(line) {
+ const dateIsBad = badDate(line)
+ if(badDate(line)) {
+ console.log(fixDate(line))
+ }else{
+ console.log(line)
+ }
+ }
+ }
+ })
+}
+
+main()