From a31cf66d9400059752a2c480bac132960383a8d9 Mon Sep 17 00:00:00 2001 From: historia Date: Fri, 16 Aug 2024 23:52:17 -0400 Subject: feat: parsing times to sort events works besides ugly edge cases --- src/soon.nim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/soon.nim') diff --git a/src/soon.nim b/src/soon.nim index cede38c..2c5f109 100644 --- a/src/soon.nim +++ b/src/soon.nim @@ -35,7 +35,7 @@ proc createDefaultCalendarFile(file: string) = if not fileExists(file): writeFile(file, "# This is your first calendar file. Put events and todos in here.") -proc getCalendarFileLines(file: string): seq[string] = +proc getFileLines(file: string): seq[string] = let f = open(file) for line in f.lines: if line == "": continue @@ -43,11 +43,13 @@ proc getCalendarFileLines(file: string): seq[string] = result.add(line) f.close() -proc processCalendars(calendarPath: string, past: int, future: int) = - var calendar = newSeq[string]() - for file in os.walkDirRec(calendarPath): +proc readAllSoonFiles(path: string): seq[string] = + for file in os.walkDirRec(path): if file.toLower().endsWith(".soon"): - calendar = calendar.concat(getCalendarFileLines(file)) + result = result.concat(getFileLines(file)) + +proc processCalendars(path: string, past: int, future: int) = + var calendar = readAllSoonFiles(path) agenda.printAgenda(calendar, past, future) todos.printTodos(calendar) -- cgit v1.2.3