From 8e83c9067e39d81cee41ad4402cb4d7c03070b52 Mon Sep 17 00:00:00 2001 From: NaddH1 <156128483+NaddH1@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:55:37 +0300 Subject: [PATCH] date fix + master merge (#761) * date fix --- plugins/english/genesistl.ts | 38 +++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/plugins/english/genesistl.ts b/plugins/english/genesistl.ts index 506a9cf..b95a95a 100644 --- a/plugins/english/genesistl.ts +++ b/plugins/english/genesistl.ts @@ -100,15 +100,39 @@ class Genesis implements Plugin.PluginBase { .text() .trim(); - if (!releaseDate) return; - - chapter.push({ - name: chapterName, - releaseTime: dayjs(releaseDate).toISOString(), + if (!releaseDate) return; + const months = [ + "jan", + "feb", + "mar", + "apr", + "may", + "jun", + "jul", + "aug", + "sep", + "oct", + "nov", + "dec", + ]; + const rx = new RegExp( + `(${months.join("|")}).*? (\\d{2}).*?(\\d{4})`, + "i" + ).exec(releaseDate); + if (!rx) return; + const year = +rx[3]; + const month = months.indexOf(rx[1].toLowerCase()); + const day = +rx[2]; + + if (month < 0) return; + + chapter.push({ + name: chapterName, + releaseTime: new Date(year, month, day).toISOString(), + url: chapterUrl, + }); - url: chapterUrl, - }); }); novel.chapters = chapter.reverse(); return novel;