feat(02-01): Drift tables, DAOs, scheduling utility, domain models with tests
- Add Rooms, Tasks, TaskCompletions Drift tables with schema v2 migration - Create RoomsDao with CRUD, watchAll, watchWithStats, cascade delete, reorder - Create TasksDao with CRUD, watchInRoom (sorted by due), completeTask, overdue detection - Implement calculateNextDueDate and catchUpToPresent pure scheduling functions - Define IntervalType enum (8 types), EffortLevel enum, FrequencyInterval model - Add formatRelativeDate German formatter and curatedRoomIcons icon list - Enable PRAGMA foreign_keys in beforeOpen migration strategy - All 30 unit tests passing (17 scheduling + 6 rooms DAO + 7 tasks DAO) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
18
lib/features/tasks/domain/relative_date.dart
Normal file
18
lib/features/tasks/domain/relative_date.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
/// Format a due date relative to today in German.
|
||||
///
|
||||
/// Returns labels like "Heute", "Morgen", "in X Tagen",
|
||||
/// "Uberfaellig seit 1 Tag", "Uberfaellig seit X Tagen".
|
||||
///
|
||||
/// Both [dueDate] and [today] are compared as date-only (ignoring time).
|
||||
String formatRelativeDate(DateTime dueDate, DateTime today) {
|
||||
final diff =
|
||||
DateTime(dueDate.year, dueDate.month, dueDate.day)
|
||||
.difference(DateTime(today.year, today.month, today.day))
|
||||
.inDays;
|
||||
|
||||
if (diff == 0) return 'Heute';
|
||||
if (diff == 1) return 'Morgen';
|
||||
if (diff > 1) return 'in $diff Tagen';
|
||||
if (diff == -1) return 'Uberfaellig seit 1 Tag';
|
||||
return 'Uberfaellig seit ${diff.abs()} Tagen';
|
||||
}
|
||||
Reference in New Issue
Block a user