Fix sticker seeder.

This commit is contained in:
Lucid Kobold
2022-01-03 14:07:03 -06:00
parent 71eaedea9d
commit 454ef47837
3 changed files with 21 additions and 10 deletions

View File

@@ -7,8 +7,7 @@ import { getDaysInMonth, getYear, getMonth, isBefore } from "date-fns";
*/
const generateSticker = (): -2 | -1 | 0 | 1 | 2 => {
const stickerPossibility = [-2, -1, 0, 1, 2];
const sticker = Math.floor(Math.random() * stickerPossibility.length);
const sticker = Math.floor(Math.random() * (2 - -2 + 1)) + -2;
if (
sticker === -2 ||
@@ -21,14 +20,14 @@ const generateSticker = (): -2 | -1 | 0 | 1 | 2 => {
}
};
const stickersSeeder = (): Sticker[] => {
const stickersSeeder = (): StickerDays => {
const stickers = [] as Sticker[];
const now = new Date();
const daysOfThisMonth = getDaysInMonth(now);
for (let i = 0; i <= daysOfThisMonth; i++) {
const currDate = new Date(getYear(now), getMonth(now) - 1, i);
for (let i = 1; i <= daysOfThisMonth; i++) {
const currDate = new Date(getYear(now), getMonth(now), i);
const newSticker: Sticker = {
date: currDate,