Commit 9559066b0e
Verified · cmc
Layout: unified · split
Sources/OrgCore/Commands/ClockReport.swift +3 −2
| @@ -71,7 +71,8 @@ public enum ClockReport { | ||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /// An Org table of clocked time per date and heading between `start` and `end` |
| 74 | /// (inclusive, `YYYY-MM-DD`), with a total after each ISO week. | |
| 74 | /// (inclusive, `YYYY-MM-DD`), with a total after each ISO week. The heading column is | |
| 75 | /// titled Code, for headings named by charge code. | |
| 75 | 76 | public static func timeReport(_ entries: [Entry], start: String? = nil, end: String? = nil) -> String { |
| 76 | 77 | var totals: [String: [String: Int]] = [:] |
| 77 | 78 | for entry in entries { |
| @@ -89,7 +90,7 @@ public enum ClockReport { | ||
| 89 | 90 | let dashes7 = String(repeating: "-", count: 7) |
| 90 | 91 | let rule: String = "|" + dashes14 + "+" + dashes47 + "+" + dashes7 + "|\n" |
| 91 | 92 | func row(_ a: String, _ b: String, _ c: String) -> String { "| \(pad(a, 12)) | \(pad(b, 45)) | \(padLeft(c, 5)) |\n" } |
| 92 | var out = "#+title: Time Report\n\n" + row("Date", "Heading", "Hours") + rule | |
| 93 | var out = "#+title: Time Report\n\n" + row("Date", "Code", "Hours") + rule | |
| 93 | 94 | var currentWeek: String? |
| 94 | 95 | var weekMinutes = 0 |
| 95 | 96 | for (date, heading) in keys { |
Tests/OrgCoreTests/ClockTests.swift −2
| @@ -133,9 +133,7 @@ struct ClockReportTests { | ||
| 133 | 133 | for text in texts { |
| 134 | 134 | for (start, end) in [(nil, nil), ("2026-02-18", nil), (nil, "2026-02-20"), ("2026-02-17", "2026-02-17")] as [(String?, String?)] { |
| 135 | 135 | let ours = ClockReport.timeReport(ClockReport.entries(text), start: start, end: end) |
| 136 | // The config titles the heading column "Code". | |
| 137 | 136 | let theirs = try Self.emacsReport(text, start: start, end: end) |
| 138 | .replacingOccurrences(of: "| Code |", with: "| Heading |") | |
| 139 | 137 | #expect(ours == theirs, "\(start ?? "-")..\(end ?? "-")\nours:\n\(ours)\ntheirs:\n\(theirs)") |
| 140 | 138 | } |
| 141 | 139 | } |