Common Date and Time fomatters
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tasq/utils/app_time.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
@@ -809,32 +810,6 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
return office?.name ?? ticket.officeId;
|
||||
}
|
||||
|
||||
String _formatDate(DateTime value) {
|
||||
final local = value.toLocal();
|
||||
final monthNames = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec',
|
||||
];
|
||||
final month = monthNames[local.month - 1];
|
||||
final day = local.day.toString().padLeft(2, '0');
|
||||
final year = local.year.toString();
|
||||
final hour24 = local.hour;
|
||||
final hour12 = hour24 % 12 == 0 ? 12 : hour24 % 12;
|
||||
final minute = local.minute.toString().padLeft(2, '0');
|
||||
final ampm = hour24 >= 12 ? 'PM' : 'AM';
|
||||
return '$month $day, $year $hour12:$minute $ampm';
|
||||
}
|
||||
|
||||
Future<void> _showTimelineDialog(BuildContext context, Ticket ticket) async {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
@@ -866,7 +841,7 @@ class _TicketDetailScreenState extends ConsumerState<TicketDetailScreen> {
|
||||
Widget _timelineRow(String label, DateTime? value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text('$label: ${value == null ? '—' : _formatDate(value)}'),
|
||||
child: Text('$label: ${value == null ? '—' : AppTime.formatDate(value)}'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user