fix(shopinbit): handle timestamps from the API consistently
What changed, and why it matters
This commit is a small UI fix for the ShopInBit ticket detail screen. It changes how timestamps received from the API are displayed to users, making the formatting consistent whether or not the API includes timezone information. It also adds the date (e.g., 'Jan 5') when a message is not from today. There is no security issue visible in this change.
No security action needed. Review as a normal UI/UX fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch replaces a custom DateTime formatting helper with one that always converts to local time via toLocal() and uses intl.DateFormat to prepend ‘MMM d’ for non-today messages. It removes a TODO about local time handling and adds the intl package import. The change is purely presentational and affects only the shopinbit_ticket_detail.dart widget.
Changed components
lib/pages/shopinbit/shopinbit_ticket_detail.dartInspect captured patch +11 / −8
diff --git a/lib/pages/shopinbit/shopinbit_ticket_detail.dart b/lib/pages/shopinbit/shopinbit_ticket_detail.dart
index 9875a7b..be9c71c 100644
--- a/lib/pages/shopinbit/shopinbit_ticket_detail.dart
+++ b/lib/pages/shopinbit/shopinbit_ticket_detail.dart
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:intl/intl.dart';
import '../../models/shopinbit/shopinbit_order_model.dart';
import '../../notifications/show_flush_bar.dart';
@@ -237,14 +238,16 @@ class _ShopInBitTicketDetailState extends ConsumerState<ShopInBitTicketDetail> {
}
String _formatTime(DateTime dt) {
- // TODO: local time is a start but this is still far from ideal...
- if (dt.isUtc) {
- dt = dt.toLocal();
- }
-
- final hour = dt.hour.toString().padLeft(2, '0');
- final minute = dt.minute.toString().padLeft(2, '0');
- return "$hour:$minute";
+ final local = dt.toLocal();
+ final hour = local.hour.toString().padLeft(2, '0');
+ final minute = local.minute.toString().padLeft(2, '0');
+ final hm = "$hour:$minute";
+ final now = DateTime.now();
+ final isToday =
+ local.year == now.year &&
+ local.month == now.month &&
+ local.day == now.day;
+ return isToday ? hm : "${DateFormat('MMM d').format(local)} $hm";
}
static final _imgTagRegex = RegExp(
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.