diff options
| author | historia <gravel.justness270@slmail.me> | 2024-08-16 23:52:17 -0400 |
|---|---|---|
| committer | historia <gravel.justness270@slmail.me> | 2024-08-16 23:52:17 -0400 |
| commit | a31cf66d9400059752a2c480bac132960383a8d9 (patch) | |
| tree | 99073a9056263b5ceb5d3ec5f7577ca6667766ff /src/soon.nim | |
| parent | e5c80a22c35a5745ae957b8e84da42abd0c41d4d (diff) | |
| download | soon-a31cf66d9400059752a2c480bac132960383a8d9.tar.gz | |
feat: parsing times to sort events works besides ugly edge cases
Diffstat (limited to 'src/soon.nim')
| -rw-r--r-- | src/soon.nim | 12 |
1 files changed, 7 insertions, 5 deletions
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) |
