Skip to content

Commit 8e23d9f

Browse files
author
Inderjeet Singh
committed
fix: improve due date display format in add task screen
1 parent 1ea088c commit 8e23d9f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/app/utils/taskfunctions/add_task_dialog_utils.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@ import 'package:taskwarrior/app/utils/app_settings/app_settings.dart';
33
import 'package:taskwarrior/app/utils/language/sentence_manager.dart';
44

55
String dateToStringForAddTask(DateTime dt) {
6-
return 'On ${DateFormat('yyyy-MM-dd').format(dt)} at ${DateFormat('hh:mm:ss').format(dt)}';
6+
final now = DateTime.now();
7+
final today = DateTime(now.year, now.month, now.day);
8+
final tomorrow = today.add(const Duration(days: 1));
9+
final dtDate = DateTime(dt.year, dt.month, dt.day);
10+
11+
// Format time in 12-hour format with AM/PM
12+
final timeFormat = DateFormat('h:mm a');
13+
final timeString = timeFormat.format(dt);
14+
15+
// Check if date is today or tomorrow
16+
if (dtDate == today) {
17+
return 'Today • $timeString';
18+
} else if (dtDate == tomorrow) {
19+
return 'Tomorrow • $timeString';
20+
} else {
21+
// Format: "Feb 28 • 7:50 AM"
22+
final dateFormat = DateFormat('MMM d');
23+
final dateString = dateFormat.format(dt);
24+
return '$dateString • $timeString';
25+
}
726
}
827

928
String getPriorityText(String priority) {

0 commit comments

Comments
 (0)