Last active
August 9, 2016 12:48
-
-
Save joseph-allen/4a64cf12e8d99a89aa2d2c06c5ec32f3 to your computer and use it in GitHub Desktop.
converts TV times to useful times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require('fs'); | |
moment = require('moment'); | |
var dates = [] | |
fs.readFile('times.js', 'utf8', function (err,data) { | |
if (err) { | |
return console.log(err); | |
} | |
dates = data.split('\n'); | |
dates = dates.map(function(item){ | |
console.log(moment(item,'DD/MM/YYYY HHmm').unix()) | |
return moment(item,'DD/MM/YYYY HHmm').unix(); | |
}) | |
var outputText = 'var slots = [\n'; | |
dates.forEach(function(date){ | |
if(!isNaN(date)){ | |
outputText += '\t' + date + '000,\n'; | |
} | |
}) | |
outputText = outputText.substring(0, outputText.length - 2); | |
outputText +='\n]'; | |
fs.writeFile("output.txt", outputText, function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log("The file was saved!"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment