From 1721d685858e9e25ec1719f5017e3b78da2f181f Mon Sep 17 00:00:00 2001 From: raviramnani Date: Tue, 30 Jul 2024 16:49:03 +0530 Subject: [PATCH] Added time validation if the date is same in detail_screen.dart --- evently/lib/screens/detail_screen.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/evently/lib/screens/detail_screen.dart b/evently/lib/screens/detail_screen.dart index 5d62fde20b..5cb6a9b36b 100644 --- a/evently/lib/screens/detail_screen.dart +++ b/evently/lib/screens/detail_screen.dart @@ -181,7 +181,7 @@ class _DetailsScreenState extends State { if (_validateDates(provider)) { createEventViewModel.nextPage(); } else { - _showSnackBarWithPostFrameCallback('End date cannot be before start date!'); + _showSnackBarWithPostFrameCallback('End of event cannot be before start of event!'); } }, onPressSaveDraft: () { @@ -192,7 +192,7 @@ class _DetailsScreenState extends State { uploadStep: UploadStep.detail, ); } else { - _showSnackBarWithPostFrameCallback('End date cannot be before start date!'); + _showSnackBarWithPostFrameCallback('End of event cannot be before start of event!'); } }, isContinueEnable: provider.startDate.isNotEmpty && @@ -258,6 +258,15 @@ class _DetailsScreenState extends State { if (end.isBefore(start)) { return false; // End date is before start date } + // Check times if the dates are the same + if (provider.startDate.compareTo(provider.endDate) == 0) { + final DateTime startTime = DateFormat('HH:mm').parse(provider.startTime); + final DateTime endTime = DateFormat('HH:mm').parse(provider.endTime); + + if (endTime.isBefore(startTime)) { + return false; // End time is before start time on the same day + } + } } catch (e) { return false; // Invalid date format }