{"record":{"id":"68f4185339578442","repo":"languagetool-org/languagetool","slug":"could-not-find-day-of-week-for-daystr-68f418","errorCode":null,"errorMessage":"Could not find day of week for '<dayStr>'","messagePattern":"Could not find day of week for '<dayStr>'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/pl/src/main/java/org/languagetool/rules/pl/DateCheckFilter.java","lineNumber":46,"sourceCode":"public class DateCheckFilter extends AbstractDateCheckFilter {\n\n  @Override\n  protected Calendar getCalendar() {\n    return Calendar.getInstance(Locale.forLanguageTag(\"pl\"));\n  }\n\n  @SuppressWarnings(\"ControlFlowStatementWithoutBraces\")\n  @Override\n  protected int getDayOfWeek(String dayStr) {\n    String day = dayStr.toLowerCase();\n    if (day.startsWith(\"pon\")) return Calendar.MONDAY;\n    if (day.startsWith(\"wt\")) return Calendar.TUESDAY;\n    if (day.startsWith(\"śr\")) return Calendar.WEDNESDAY;\n    if (day.startsWith(\"czw\")) return Calendar.THURSDAY;\n    if (day.equals(\"pt\") || day.startsWith(\"piątk\") || day.equals(\"piątek\")) return Calendar.FRIDAY;\n    if (day.startsWith(\"sob\")) return Calendar.SATURDAY;\n    if (day.startsWith(\"niedz\")) return Calendar.SUNDAY;\n    throw new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n  }\n\n  @Override\n  protected String getDayOfWeek(Calendar date) {\n    return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag(\"pl\"));\n  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  @Override\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.equals(\"stycznia\") || monthStr.equals(\"I\")) return 1;\n    if (mon.equals(\"lutego\") || monthStr.equals(\"II\")) return 2;\n    if (mon.equals(\"marca\") || monthStr.equals(\"III\")) return 3;\n    if (mon.equals(\"kwietnia\") || monthStr.equals(\"IV\")) return 4;\n    if (mon.equals(\"maja\") || monthStr.equals(\"V\")) return 5;\n    if (mon.equals(\"czerwca\") || monthStr.equals(\"VI\")) return 6;\n    if (mon.equals(\"lipca\") || monthStr.equals(\"VII\")) return 7;","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/pl/src/main/java/org/languagetool/rules/pl/DateCheckFilter.java#L28-L64","documentation":"The Polish DateCheckFilter maps Polish weekday tokens (pn/pon, wt, śr, czw, pt/piątk…, sob, niedz…) to Calendar constants. getDayOfWeek throws this RuntimeException when the token matches none of these patterns. The Polish mapping requires correctly accented input (śr, piątk), so encoding or deaccenting issues can cause misses.","triggerScenarios":"A rule matches a weekday token not covered by the patterns (e.g. 'pon' is covered via pn/pon branch — but variants like 'poniedziałek' partial inflections or 'sobota' inflected forms 'soboty' are handled by startsWith; anything else such as an unaccented 'sr' instead of 'śr' throws).","commonSituations":"Text with ASCII-folded Polish characters ('sr', 'piatek') from other processing steps; rule regex extended with new inflected forms not handled in the mapping.","solutions":["Add the missing inflected/abbreviated form to the appropriate branch of getDayOfWeek","Verify input encoding/normalization so 'ś' and 'ą' survive to the filter (UTF-8)","Align the rule's regex with the exact token forms the mapping recognizes"],"exampleFix":"// before\nif (day.startsWith(\"niedz\")) return Calendar.SUNDAY;\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n// after\nif (day.startsWith(\"niedz\")) return Calendar.SUNDAY;\nif (day.equals(\"pon\") || day.startsWith(\"poniedzial\") || day.startsWith(\"poniedział\")) return Calendar.MONDAY; // add missing forms as needed\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");","handlingStrategy":"validation","validationCode":"if (dayStr == null || !dayStr.matches(\"(?i)(pn|pon.*|wt.*|śr.*|czw.*|pt|piątk.*|piątek|sob.*|niedz.*)\")) throw new IllegalArgumentException(\"Unrecognized Polish weekday: \" + dayStr);","typeGuard":"boolean isPolishWeekday(String s) { String d = s == null ? \"\" : s.toLowerCase(); return d.startsWith(\"pn\")||d.startsWith(\"wt\")||d.startsWith(\"śr\")||d.startsWith(\"czw\")||d.equals(\"pt\")||d.startsWith(\"piątk\")||d.startsWith(\"sob\")||d.startsWith(\"niedz\"); }","tryCatchPattern":"try { day = filter.getDayOfWeek(dayStr); } catch (RuntimeException e) { log.warn(\"Polish weekday unmatched: {}\", dayStr); /* ignore match */ }","preventionTips":["Ensure UTF-8 handling end-to-end so 'ś'/'ą' are not mangled to 's'/'a'","Test inflected weekday forms your regex can produce","Add every regex alternative to a mapping-coverage test"],"tags":["java","nlp","grammar-rules","date-validation","unicode"],"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"}