feat: merged stats and tankstats

This commit is contained in:
TresAbhi committed 2023-06-19 17:35:28 +00:00
1 parent 0cf0e63fda
commit d9690460d5
14 files changed
+195 -338

No files matched your search

+5 -11
View File
@@ -1,18 +1,12 @@
import { StatPeriod } from '../options/addPeriodChoices.js';
import getPeriodStartFromDaysAgo from './getPeriodStartFromDaysAgo.js';
import { Period } from '../options/addPeriodSubCommands.js';
import getTimeDaysAgo from './getTimeDaysAgo.js';
export default function getPeriodicStart(period: StatPeriod) {
export default function getPeriodStart(period: Exclude<Period, 'custom'>) {
if (period === 'career') {
return -Infinity;
} else if (period === 'today') {
const now = new Date();
now.setHours(5, 0, 0, 0);
// If it's after 5:00 AM today, subtract one day
if (now.getTime() > Date.now()) now.setDate(now.getDate() - 1);
return now.getTime() / 1000;
return getTimeDaysAgo(0);
} else {
return getPeriodStartFromDaysAgo(Number(period));
return getTimeDaysAgo(Number(period));
}
}