Last active
April 11, 2019 05:51
-
-
Save wifeofvillon/681f06394af53caad00add5142615c5b to your computer and use it in GitHub Desktop.
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
{ | |
const setDigits = (number) => { | |
let string = number < 10 ? `0${number}`: `${number}`; | |
return string; | |
}; | |
const pixivTimeToDate = (pixivTime) => { | |
let date = new Date(pixivTime * 1000); | |
let dateString = `${date.getFullYear()}`; | |
dateString = `${dateString}/${setDigits(date.getMonth() + 1)}/${setDigits(date.getDate())} ${setDigits(date.getHours())}:${setDigits(date.getMinutes())}`; | |
return dateString; | |
}; | |
const spanDiff = 60 * 60 * 6; | |
const chartBarCount = 4 * 7; | |
const getChartDateList = () => { | |
let chartDateList = new Array(); | |
for (var i = 0; i < chartBarCount; i++) { | |
chartDateList[i] = pixiv.context.chartStartDate + (spanDiff * i); | |
} | |
return chartDateList; | |
}; | |
const chartDateList = getChartDateList(); | |
let dataStrings = new Array(); | |
for (var i = 0; i < chartDateList.length; i++) { | |
let flag = false; | |
for (chartData of pixiv.context.chartData) { | |
if (chartDateList[i] === chartData[0]) { | |
dataStrings.push(`${pixivTimeToDate(chartDateList[i])}\t${(chartData[1] + chartData[2] + chartData[3])}`); | |
flag = true; | |
break; | |
} | |
} | |
if (!flag) { | |
dataStrings.push(`${pixivTimeToDate(chartDateList[i])}\t0`); | |
} | |
} | |
console.log(dataStrings.join("\n")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment