diff --git a/jrnl/journals/FolderJournal.py b/jrnl/journals/FolderJournal.py index 9cabbba97..00416e7db 100644 --- a/jrnl/journals/FolderJournal.py +++ b/jrnl/journals/FolderJournal.py @@ -17,6 +17,7 @@ DIGIT_PATTERN = "[0123456789]" YEAR_PATTERN = DIGIT_PATTERN * 4 MONTH_PATTERN = "[01]" + DIGIT_PATTERN +DAY_PATTERN = "[0-3][0-9]" DEFAULT_EXTENSION = ".txt" @@ -148,15 +149,15 @@ def _get_month_folders(path: pathlib.Path) -> list[pathlib.Path]: @staticmethod def _get_day_files(path: pathlib.Path, extension: str) -> list[str]: - DAY_PATTERN = "[0-3][0-9]" + extension - for child in path.glob(DAY_PATTERN): + for child in path.glob(DAY_PATTERN + extension): + day = str(child.name).replace(extension, "") if ( - int(child.stem) > 0 - and int(child.stem) <= 31 + int(day) > 0 + and int(day) <= 31 and time.is_valid_date( year=int(path.parent.name), month=int(path.name), - day=int(child.stem), + day=int(day), ) and child.is_file() ):