Created
June 13, 2018 23:00
-
-
Save slayerlab/a8b5c60f5053b203d9fe95f9384aeef0 to your computer and use it in GitHub Desktop.
[PoC, NodeJS] A workaround to convert time from NVDCVE feed to SecurityFocus.
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/node | |
'use strict'; | |
String.prototype.bidTimeConvert = function () { | |
let month = ['Jan', 'Feb', 'Mar', 'Apr', 'Mar', 'May', 'Jun', 'Jul', 'Ago', 'Set', 'Oct', 'Nov', 'Dec']; | |
let fromTime = new Date(this.toString().split('.')[0]).toLocaleString(); | |
let fromMinutes = ((new Date(fromTime).getMinutes()).toString().length == 1) ? '0'+new Date(fromTime).getMinutes() : new Date(fromTime).getMinutes(); | |
return (new Date(fromTime).getHours() < 12) | |
? month[new Date(fromTime).getMonth()+1] +' '+new Date(fromTime).getDate()+' '+new Date(fromTime).getFullYear()+' '+(new Date(fromTime).getHours() + 12)+':'+fromMinutes+'AM' | |
: month[new Date(fromTime).getMonth()+1] +' '+new Date(fromTime).getDate()+' '+new Date(fromTime).getFullYear()+' '+new Date(fromTime).getHours()+':'+fromMinutes+'PM'; | |
} | |
console.log('1998-07-20T00:00:00.000-04:00'.bidTimeConvert()); | |
console.log('2008-09-05T16:16:20.580-04:00'.bidTimeConvert()); | |
console.log('2006-05-01T12:00:00.000-04:00'.bidTimeConvert()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: