fix: [NovelDeGlace] Correct Invalid Date(#1056)

This commit is contained in:
Elfing
2024-07-15 07:44:34 +02:00
committed by GitHub
parent 13a3c2dd02
commit e24d590728
2 changed files with 33 additions and 31 deletions
+16 -15
View File
@@ -11,7 +11,7 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
name = 'NovelDeGlace'; name = 'NovelDeGlace';
icon = 'src/fr/noveldeglace/icon.png'; icon = 'src/fr/noveldeglace/icon.png';
site = 'https://noveldeglace.com/'; site = 'https://noveldeglace.com/';
version = '1.0.2'; version = '1.0.3';
async getCheerio(url: string): Promise<CheerioAPI | undefined> { async getCheerio(url: string): Promise<CheerioAPI | undefined> {
const r = await fetchApi(url, { const r = await fetchApi(url, {
@@ -24,25 +24,26 @@ class NovelDeGlacePlugin implements Plugin.PluginBase {
} }
parseDate(date: string): string { parseDate(date: string): string {
const monthMapping: Record<string, string> = { const monthMapping: Record<string, number> = {
janvier: 'January', janvier: 1,
fevrier: 'February', fevrier: 2,
mars: 'March', mars: 3,
avril: 'April', avril: 4,
mai: 'May', mai: 5,
juin: 'June', juin: 6,
juillet: 'July', juillet: 7,
aout: 'August', aout: 8,
septembre: 'September', septembre: 9,
octobre: 'October', octobre: 10,
novembre: 'November', novembre: 11,
decembre: 'December', decembre: 12,
}; };
const [day, month, year] = date.split(' '); const [day, month, year] = date.split(' ');
return dayjs( return dayjs(
`${day} ${monthMapping[month.normalize('NFD').replace(/[\u0300-\u036f]/g, '')]} ${year}`, `${day} ${monthMapping[month.normalize('NFD').replace(/[\u0300-\u036f]/g, '')]} ${year}`,
'D MMMM YYYY', 'D MMMM YYYY',
).format('YYYY-MM-DD'); ).format('DD MMMM YYYY');
} }
parseNovels( parseNovels(
+17 -16
View File
@@ -11,7 +11,7 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
name = 'PhenixScans'; name = 'PhenixScans';
icon = 'src/fr/phenixscans/icon.png'; icon = 'src/fr/phenixscans/icon.png';
site = 'https://phenixscans.fr'; site = 'https://phenixscans.fr';
version = '1.0.0'; version = '1.0.1';
async getCheerio(url: string): Promise<CheerioAPI> { async getCheerio(url: string): Promise<CheerioAPI> {
const r = await fetchApi(url); const r = await fetchApi(url);
@@ -98,25 +98,26 @@ class PhenixScansTradPlugin implements Plugin.PluginBase {
} }
parseDate(date: string): string { parseDate(date: string): string {
const monthMapping: Record<string, string> = { const monthMapping: Record<string, number> = {
janvier: 'January', janvier: 1,
fevrier: 'February', fevrier: 2,
mars: 'March', mars: 3,
avril: 'April', avril: 4,
mai: 'May', mai: 5,
juin: 'June', juin: 6,
juillet: 'July', juillet: 7,
aout: 'August', aout: 8,
septembre: 'September', septembre: 9,
octobre: 'October', octobre: 10,
novembre: 'November', novembre: 11,
decembre: 'December', decembre: 12,
}; };
const [month, day, year] = date.split(' ');
const [day, month, year] = date.split(' ');
return dayjs( return dayjs(
`${day} ${monthMapping[month.normalize('NFD').replace(/[\u0300-\u036f]/g, '')]} ${year}`, `${day} ${monthMapping[month.normalize('NFD').replace(/[\u0300-\u036f]/g, '')]} ${year}`,
'D MMMM YYYY', 'D MMMM YYYY',
).format('YYYY-MM-DD'); ).format('DD MMMM YYYY');
} }
getStatus(status: string) { getStatus(status: string) {