5681b39 ←c829a75antonApr 8, 2026 api

edit version-view.ts via macOS

M /sublimated/undefined +47 -0
162 unmodified lines
163 // cleanup handled by obsidian
164 }
165}
166
167interface DayGroup {
168 label: string;
169 versions: Version[];
170}
171
172function groupByDay(versions: Version[]): DayGroup[] {
173 const groups = new Map<string, Version[]>();
174 const order: string[] = [];
175
176 for (const v of versions) {
177 const label = formatDayLabel(v.createdAt);
178 if (!groups.has(label)) {
179 groups.set(label, []);
180 order.push(label);
181 }
182 groups.get(label)!.push(v);
183 }
184
185 return order.map((label) => ({
186 label,
187 versions: groups.get(label)!,
188 }));
189}
190
191function formatDayLabel(iso: string): string {
192 const now = new Date();
193 const date = new Date(iso);
194
195 const nowDay = new Date(now.getFullYear(), now.getMonth(), now.getDate());
196 const thenDay = new Date(
197 date.getFullYear(),
198 date.getMonth(),
199 date.getDate()
200 );
201 const days = Math.round(
202 (nowDay.getTime() - thenDay.getTime()) / (1000 * 60 * 60 * 24)
203 );
204
205 if (days === 0) return "Today";
206 if (days === 1) return "Yesterday";
207 if (days < 7) return `${days} days ago`;
208 return date.toLocaleDateString("en-US", {
209 month: "short",
210 day: "numeric",
211 });
212}
213
214function formatRelativeTime(iso: string): string {
215 const now = Date.now();
216 const then = new Date(iso).getTime();
217 const diff = now - then;
11 unmodified lines