Commit b3ba6ca101
Verified · cmc
Layout: unified · split
Sources/OrgCore/Agenda/Reminders.swift +5 −4
| @@ -43,11 +43,12 @@ public enum Reminders { | ||
| 43 | 43 | event > now else { continue } |
| 44 | 44 | let fire = max(event.addingTimeInterval(-Double((item.warntime ?? lead) * 60)), now.addingTimeInterval(1)) |
| 45 | 45 | let clockText = String(format: "%d:%02d", time / 100, time % 100) |
| 46 | let title = item.text.trimmingCharacters(in: .whitespaces) | |
| 47 | let leader = item.extra.trimmingCharacters(in: .whitespaces) | |
| 46 | // `Scheduled:` reads `Scheduled` beside the time. | |
| 47 | var leader = item.extra.trimmingCharacters(in: .whitespaces) | |
| 48 | if leader.hasSuffix(":") { leader.removeLast() } | |
| 48 | 49 | reminders.append(Reminder( |
| 49 | id: "orgstar.\(path)|\(item.headingLine ?? title)|\(day.day)|\(time)|\(item.kind.rawValue)", | |
| 50 | fireDate: fire, eventDate: event, title: title, | |
| 50 | id: "orgstar.\(path)|\(item.headingLine ?? item.text.trimmingCharacters(in: .whitespaces))|\(day.day)|\(time)|\(item.kind.rawValue)", | |
| 51 | fireDate: fire, eventDate: event, title: item.title, | |
| 51 | 52 | body: ([clockText] + (leader.isEmpty ? [] : [leader]) + [item.category]).joined(separator: " · "), |
| 52 | 53 | path: path, offset: item.markerOffset ?? item.headingOffset ?? 0 |
| 53 | 54 | )) |
Tests/OrgCoreTests/AgendaTests.swift +4 −4
| @@ -411,7 +411,7 @@ struct ReminderTests { | ||
| 411 | 411 | |
| 412 | 412 | @Test func timedEntriesWithTheirWarnings() { |
| 413 | 413 | let text = """ |
| 414 | * TODO Call | |
| 414 | * TODO [#A] Call [1/2] | |
| 415 | 415 | SCHEDULED: <2026-10-05 Mon 14:00> |
| 416 | 416 | * Meeting |
| 417 | 417 | :PROPERTIES: |
| @@ -432,14 +432,14 @@ struct ReminderTests { | ||
| 432 | 432 | let source = AgendaSource(path: "/n/a.org", text: text) |
| 433 | 433 | let now = Self.date(5, 9, 30) |
| 434 | 434 | let reminders = Reminders.upcoming([source], now: now, calendar: Self.utc) |
| 435 | #expect(reminders.map(\.title) == ["Soon", "TODO Call", "Meeting", "TODO Report due"]) | |
| 435 | #expect(reminders.map(\.title) == ["Soon", "Call", "Meeting", "Report due"]) | |
| 436 | 436 | #expect(reminders[0].fireDate == now.addingTimeInterval(1)) |
| 437 | 437 | #expect(reminders[1].fireDate == Self.date(5, 13, 48)) |
| 438 | #expect(reminders[1].body == "14:00 · Scheduled: · a") | |
| 438 | #expect(reminders[1].body == "14:00 · Scheduled · a") | |
| 439 | 439 | #expect(reminders[2].fireDate == Self.date(6, 9, 30)) |
| 440 | 440 | #expect(reminders[3].eventDate == Self.date(7, 17, 0)) |
| 441 | 441 | #expect(Reminders.upcoming([source], now: now, calendar: Self.utc, limit: 2).count == 2) |
| 442 | #expect(Reminders.upcoming([source], now: now, calendar: Self.utc, days: 1).map(\.title) == ["Soon", "TODO Call"]) | |
| 442 | #expect(Reminders.upcoming([source], now: now, calendar: Self.utc, days: 1).map(\.title) == ["Soon", "Call"]) | |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | @Test func repeatsFillTheWeek() { |