From 5953fb376b392d04a324c5515d043a0749002bb3 Mon Sep 17 00:00:00 2001 From: Raiyn Aydin Date: Thu, 15 Oct 2026 19:36:52 +0800 Subject: [PATCH 1/3] fix(portuguese/tsundoku): parse DD/MM/YYYY chapter dates The site now shows chapter release dates as DD/MM/YYYY (e.g. "17/07/2024"). parseDate expected "month day, year" text, so the split produced undefined parts and dayjs(...).toISOString() threw "Invalid time value", failing parseNovel on every novel. parseDate now reads DD/MM/YYYY, still accepts the older month-name layout, and returns null for a missing or unrecognised date instead of throwing. Version 1.0.1 -> 1.0.2. --- plugins/portuguese/tsundoku.ts | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/plugins/portuguese/tsundoku.ts b/plugins/portuguese/tsundoku.ts index 5dd4204b5..124192e76 100644 --- a/plugins/portuguese/tsundoku.ts +++ b/plugins/portuguese/tsundoku.ts @@ -8,11 +8,11 @@ import { Filters, FilterTypes } from '@libs/filterInputs'; class TsundokuPlugin implements Plugin.PluginBase { id = 'tsundoku'; name = 'Tsundoku Traduções'; - version = '1.0.1'; + version = '1.0.2'; icon = 'src/pt-br/tsundoku/icon.png'; site = 'https://tsundoku.com.br'; - parseDate(date: string): string { + parseDate(date: string): string | null { const monthMapping: Record = { janeiro: 1, fevereiro: 2, @@ -27,10 +27,31 @@ class TsundokuPlugin implements Plugin.PluginBase { novembro: 11, dezembro: 12, }; - const [month, day, year] = date.split(/,?\s+/); - return dayjs( - `${year}-${monthMapping[month.normalize('NFD').replace(/[\u0300-\u036f]/g, '')]}-${day}`, - ).toISOString(); + const text = date.trim(); + + // Current layout is DD/MM/YYYY (e.g. "17/07/2024"); the older + // "janeiro 5, 2024" month-name layout is still accepted. + const numeric = text.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/); + let day: string; + let month: number | string | undefined; + let year: string; + if (numeric) { + day = numeric[1]; + month = Number(numeric[2]); + year = numeric[3]; + } else { + const [monthName = '', dayText = '', yearText = ''] = text.split(/,?\s+/); + day = dayText; + year = yearText; + month = + monthMapping[ + monthName.normalize('NFD').replace(/[\u0300-\u036f]/g, '') + ]; + } + + // A missing or unrecognised date must not throw; the chapter just has no release time. + const parsed = dayjs(`${year}-${month}-${day}`); + return parsed.isValid() ? parsed.toISOString() : null; } parseNovels(loadedCheerio: CheerioAPI) { From 06ca9a1a3a591887169a74b8cb89320d6d72fa19 Mon Sep 17 00:00:00 2001 From: Raiyn Aydin Date: Thu, 15 Oct 2026 19:41:52 +0800 Subject: [PATCH 2/3] no-mistakes(review): Drop legacy month-name date parsing from tsundoku --- plugins/portuguese/tsundoku.ts | 41 +++++----------------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/plugins/portuguese/tsundoku.ts b/plugins/portuguese/tsundoku.ts index 124192e76..c8e8519ea 100644 --- a/plugins/portuguese/tsundoku.ts +++ b/plugins/portuguese/tsundoku.ts @@ -13,44 +13,13 @@ class TsundokuPlugin implements Plugin.PluginBase { site = 'https://tsundoku.com.br'; parseDate(date: string): string | null { - const monthMapping: Record = { - janeiro: 1, - fevereiro: 2, - marco: 3, - abril: 4, - maio: 5, - junho: 6, - julho: 7, - agosto: 8, - setembro: 9, - outubro: 10, - novembro: 11, - dezembro: 12, - }; - const text = date.trim(); - - // Current layout is DD/MM/YYYY (e.g. "17/07/2024"); the older - // "janeiro 5, 2024" month-name layout is still accepted. - const numeric = text.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/); - let day: string; - let month: number | string | undefined; - let year: string; - if (numeric) { - day = numeric[1]; - month = Number(numeric[2]); - year = numeric[3]; - } else { - const [monthName = '', dayText = '', yearText = ''] = text.split(/,?\s+/); - day = dayText; - year = yearText; - month = - monthMapping[ - monthName.normalize('NFD').replace(/[\u0300-\u036f]/g, '') - ]; - } + const match = date.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/); + if (!match) return null; + + const [, day, month, year] = match; // A missing or unrecognised date must not throw; the chapter just has no release time. - const parsed = dayjs(`${year}-${month}-${day}`); + const parsed = dayjs(`${year}-${Number(month)}-${day}`); return parsed.isValid() ? parsed.toISOString() : null; } From e763254df097920e8deeafc8b86dfd8a8e651930 Mon Sep 17 00:00:00 2001 From: Raiyn Aydin Date: Thu, 15 Oct 2026 19:43:16 +0800 Subject: [PATCH 3/3] no-mistakes(review): Reject impossible calendar dates in tsundoku parseDate --- plugins/portuguese/tsundoku.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/portuguese/tsundoku.ts b/plugins/portuguese/tsundoku.ts index c8e8519ea..1a166374e 100644 --- a/plugins/portuguese/tsundoku.ts +++ b/plugins/portuguese/tsundoku.ts @@ -20,7 +20,11 @@ class TsundokuPlugin implements Plugin.PluginBase { // A missing or unrecognised date must not throw; the chapter just has no release time. const parsed = dayjs(`${year}-${Number(month)}-${day}`); - return parsed.isValid() ? parsed.toISOString() : null; + const isCalendarDate = + parsed.isValid() && + parsed.date() === Number(day) && + parsed.month() === Number(month) - 1; + return isCalendarDate ? parsed.toISOString() : null; } parseNovels(loadedCheerio: CheerioAPI) {