{"record":{"id":"f2e92e3292348d96","repo":"languagetool-org/languagetool","slug":"could-not-find-day-of-week-for-daystr-f2e92e","errorCode":null,"errorMessage":"Could not find day of week for '\" + dayStr + \"'","messagePattern":"Could not find day of week for '\" \\+ dayStr \\+ \"'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DateFilterHelper.java","lineNumber":43,"sourceCode":" * @since 4.3\n */\nclass DateFilterHelper {\n\n  protected Calendar getCalendar() {\n    return Calendar.getInstance(Locale.FRENCH);\n  }\n\n  @SuppressWarnings(\"ControlFlowStatementWithoutBraces\")\n  protected int getDayOfWeek(String dayStr) {\n    String day = dayStr.toLowerCase();\n    if (day.startsWith(\"dim\")) return Calendar.SUNDAY;\n    if (day.startsWith(\"lun\")) return Calendar.MONDAY;\n    if (day.startsWith(\"mar\")) return Calendar.TUESDAY;\n    if (day.startsWith(\"mer\")) return Calendar.WEDNESDAY;\n    if (day.startsWith(\"jeu\")) return Calendar.THURSDAY;\n    if (day.startsWith(\"ven\")) return Calendar.FRIDAY;\n    if (day.startsWith(\"sam\")) return Calendar.SATURDAY;\n    throw new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n  }\n\n  \n  protected String getDayOfWeek(Calendar date) {\n    return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.FRENCH);\n  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.startsWith(\"jan\")) return 1;\n    if (mon.startsWith(\"fév\")) return 2;\n    if (mon.startsWith(\"fev\")) return 2;\n    if (mon.startsWith(\"mar\")) return 3;\n    if (mon.startsWith(\"avr\")) return 4;\n    if (mon.startsWith(\"mai\")) return 5;\n    // \"juin\" and \"juillet\" are never abbreviated with 3 letters\n    // since it would be ambiguous (both start with \"jui\").","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DateFilterHelper.java#L25-L61","documentation":"DateFilterHelper.getDayOfWeek maps French weekday strings (lun.., mar.., mer.., jeu.., ven.., sam..) to java.util.Calendar constants. When none of the startsWith prefixes match, it throws this RuntimeException because the weekday argument of a date rule could not be interpreted.","triggerScenarios":"A French grammar rule passes a 'weekDay'-like argument whose lowercase value does not start with lun/mar/mer/jeu/ven/sam — e.g. 'dim' (dimanche, which is not in the list), misspellings, English weekday names, or empty string.","commonSituations":"Sunday: rules referencing 'dimanche' hit the gap in the prefix table; abbreviations with unusual casing handled upstream differently; translations of rules from other languages carry non-French weekday words.","solutions":["Fix the rule argument to a French weekday covered by the filter (lundi..samedi).","If 'dimanche' (Sunday) is needed, extend getDayOfWeek with `if (day.startsWith(\"dim\")) return Calendar.SUNDAY;` before the throw.","Normalize the input (lowercase, trim, expand abbreviations) before calling the filter."],"exampleFix":"// before\nif (day.startsWith(\"sam\")) return Calendar.SATURDAY;\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n// after\nif (day.startsWith(\"sam\")) return Calendar.SATURDAY;\nif (day.startsWith(\"dim\")) return Calendar.SUNDAY;\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");","handlingStrategy":"validation","validationCode":"Set<String> validPrefixes = Set.of(\"lun\",\"mar\",\"mer\",\"jeu\",\"ven\",\"sam\");\nString d = dayStr == null ? \"\" : dayStr.toLowerCase().trim();\nif (validPrefixes.stream().noneMatch(d::startsWith)) {\n    throw new IllegalArgumentException(\"Unsupported weekday: \" + dayStr);\n}","typeGuard":null,"tryCatchPattern":"try { int dow = helper.getDayOfWeek(cal); } catch (RuntimeException e) { LOG.warn(\"Unmapped weekday: \" + e.getMessage()); }","preventionTips":["Only pass French weekday names covered by the prefix list.","Patch getDayOfWeek to include 'dim' (Sunday) if dimanche rules are used.","Lowercase and trim weekday args before the filter runs."],"tags":["java","languagetool","french","date-parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}