feat: used dahses for command readibility

This commit is contained in:
TresAbhi committed 2023-08-04 02:24:14 +00:00
1 parent 23dd088466
commit 91f364b76a
13 files changed
+37 -49

No files matched your search

+3 -12
View File
@@ -1,16 +1,7 @@
import { Region } from '../../constants/regions';
import { Period } from '../discord/addPeriodSubCommands';
import { PeriodOption } from '../discord/addPeriodSubCommands';
import getTimeDaysAgo from './getTimeDaysAgo';
export default function getPeriodStart(
server: Region,
period: Exclude<Period, 'customperiod'>,
) {
if (period === 'career') {
return -Infinity;
} else if (period === 'today') {
return getTimeDaysAgo(server, 1);
} else {
return getTimeDaysAgo(server, parseInt(period.match(/\d+/)?.[0]!));
}
export default function getPeriodStart(region: Region, period: PeriodOption) {
return period === 'career' ? 0 : getTimeDaysAgo(region, parseInt(period));
}
+2 -2
View File
@@ -6,13 +6,13 @@ export const TIME_ZONE_MAPPINGS: Record<Region, number> = {
asia: +7, // Central Asia Standard Time
};
export default function getTimeDaysAgo(server: Region, daysAgo: number) {
export default function getTimeDaysAgo(region: Region, daysAgo: number) {
const now = new Date();
if (daysAgo === 0) now.getTime() / 1000;
const time = new Date();
time.setUTCHours(-TIME_ZONE_MAPPINGS[server], 0, 0, 0);
time.setUTCHours(-TIME_ZONE_MAPPINGS[region], 0, 0, 0);
if (time > now) time.setUTCDate(time.getUTCDate() - 1);
time.setUTCDate(time.getUTCDate() - daysAgo + 1);