From d3a6f60d81f94f8730f63c257946ae1fbe9ebf39 Mon Sep 17 00:00:00 2001 From: Bruno Bernardino Date: Sat, 30 Mar 2024 18:10:06 +0000 Subject: [PATCH] Minor code cleanup --- lib/utils/calendar.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/utils/calendar.ts b/lib/utils/calendar.ts index d7e2ba5..870e818 100644 --- a/lib/utils/calendar.ts +++ b/lib/utils/calendar.ts @@ -567,7 +567,6 @@ const rRuleToFrequencyOrWeekDay = new Map ['SU', 'Sunday'], ]); -// check if multiple days and format either way function convertRRuleDaysToWords(day: string | RRuleFrequency | RRuleWeekDay): string { if (day.includes(',')) { const days = day.split(',') as (typeof day)[]; @@ -578,7 +577,6 @@ function convertRRuleDaysToWords(day: string | RRuleFrequency | RRuleWeekDay): s return rRuleToFrequencyOrWeekDay.get(day as RRuleFrequency | RRuleWeekDay)!; } -// convert to ordinal number function getOrdinalSuffix(number: number) { const text = ['th', 'st', 'nd', 'rd'] as const; const value = number % 100; @@ -607,10 +605,6 @@ export function convertRRuleToWords(rRule: string): string { const count = parsedRRule.COUNT; const interval = parsedRRule.INTERVAL; - // TODO: Remove this - console.log('==== File.method'); - console.log(JSON.stringify({}, null, 2)); - const words: string[] = []; if (frequency === 'DAILY') { @@ -637,7 +631,7 @@ export function convertRRuleToWords(rRule: string): string { if (frequency === 'WEEKLY') { if (byDay) { - if (interval && parseInt(interval) > 1) { + if (interval && parseInt(interval, 10) > 1) { words.push( `Every ${interval} ${rRuleToFrequencyOrWeekDay.get(frequency)}s on ${convertRRuleDaysToWords(byDay)}`, ); @@ -663,7 +657,7 @@ export function convertRRuleToWords(rRule: string): string { // monthly if (frequency === 'MONTHLY' && byMonthDay) { - if (interval && parseInt(interval) > 1) { + if (interval && parseInt(interval, 10) > 1) { words.push( `Every ${interval} ${rRuleToFrequencyOrWeekDay.get(frequency)}s on the ${ getOrdinalSuffix(parseInt(byMonthDay, 10))