Created
March 18, 2014 23:37
-
-
Save raineorshine/9632311 to your computer and use it in GitHub Desktop.
A simple node script to convert a file of date strings to milliseconds.
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
./dateparse.js dates.txt out.txt |
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
#!/usr/bin/env node | |
var fs = require('fs'); | |
// load file | |
var datesText = fs.readFileSync(process.argv[2]).toString(); | |
// convert date strings to milliseconds | |
var times = datesText | |
.split('\n') | |
.map(function(dateString) { | |
return new Date(dateString).getTime(); | |
}) | |
.join('\n'); | |
// write times to output file | |
fs.writeFile(process.argv[3], 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
2014-03-10 00:00 | |
2014-03-18 00:00 | |
2014-04-01 00:00 |
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
1394431200000 | |
1395122400000 | |
1396332000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment