From 62178bd7c6f062fe5da2fbf7f0ad88f7ac3b9040 Mon Sep 17 00:00:00 2001 From: iosabi Date: Sun, 30 Mar 2025 12:04:04 +0200 Subject: [PATCH] Fix handling of timezones in the date picker The API returns UTC datetimes, like "2025-03-29T18:22:10.681Z" but we want the user to pick times in their local timezone like in the web UI. `DateTime.now()` already returns a local time, so all we have to do is convert the UTC time to local when displaying in the widget and back to UTC afterwards. --- lib/widgets/list_list.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/widgets/list_list.dart b/lib/widgets/list_list.dart index eb77ba5..f12018f 100644 --- a/lib/widgets/list_list.dart +++ b/lib/widgets/list_list.dart @@ -665,7 +665,7 @@ class _ListListState extends State { } Widget buildDueDateWidgetPreview(String newDueDate, String cardId){ - DateTime dueDate = DateTime.parse(newDueDate); + DateTime dueDate = DateTime.parse(newDueDate).toLocal(); DateTime now = DateTime.now(); bool isOverdue = dueDate.isBefore(now); @@ -681,7 +681,7 @@ class _ListListState extends State { // Check if the due date result is already in the cache - if (dueDateCache.containsKey(dueDate)) { + if (dueDateCache.containsKey(dueDate.toString())) { // Cache the calculated due date result dueDateCache[dueDate.toString()] = result; } @@ -695,7 +695,7 @@ class _ListListState extends State { ///Update Card Due Date if(dateTime != null) { - await Provider.of(context, listen: false).updateCardDueDate(cardId: cardId, newDueDate: dateTime.toString()).then((_) { + await Provider.of(context, listen: false).updateCardDueDate(cardId: cardId, newDueDate: dateTime.toUtc().toString()).then((_) { // Call the onRefresh callback if it exists if (widget.onRefresh != null) { widget.onRefresh!();