From 98803e56cfad8ffe77471c25947c53d381c09577 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 20 Aug 2025 15:51:46 +0300 Subject: [PATCH] fix: Issue-618 --- lib/core/utils/date_time_utils.dart | 35 +++++++++++++------ .../menu/presentation/pages/menu_screen.dart | 3 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/core/utils/date_time_utils.dart b/lib/core/utils/date_time_utils.dart index bcc82aeb..701fa80e 100644 --- a/lib/core/utils/date_time_utils.dart +++ b/lib/core/utils/date_time_utils.dart @@ -3,11 +3,30 @@ import 'package:intl/intl.dart'; const String dateTimeFormatPattern = 'dd/MM/yyyy'; +/// Преобразует дату из формата гггг-мм-дд чч:мм:сс в дд.мм.гггг +String formatBuildDate(String dateString) { + if (dateString.isEmpty) return ''; + + try { + final dateTimeParts = dateString.split(' '); + if (dateTimeParts.isNotEmpty) { + final datePart = dateTimeParts[0]; + final dateParts = datePart.split('-'); + if (dateParts.length == 3) { + final year = dateParts[0]; + final month = dateParts[1]; + final day = dateParts[2]; + return '$day.$month.$year'; + } + } + } catch (e) { + return dateString; + } + return dateString; +} + extension DateTimeExtension on DateTime { - String format([ - String pattern = dateTimeFormatPattern, - String? locale, - ]) { + String format([String pattern = dateTimeFormatPattern, String? locale]) { final localDate = isUtc ? toLocal() : this; if (locale != null && locale.isNotEmpty) { initializeDateFormatting(locale); @@ -19,17 +38,13 @@ extension DateTimeExtension on DateTime { final localDate = isUtc ? toLocal() : this; final now = DateTime.now(); final yesterday = DateTime(now.year, now.month, now.day).subtract(const Duration(days: 1)); - return localDate.year == yesterday.year && - localDate.month == yesterday.month && - localDate.day == yesterday.day; + return localDate.year == yesterday.year && localDate.month == yesterday.month && localDate.day == yesterday.day; } bool isToday() { final localDate = isUtc ? toLocal() : this; final now = DateTime.now(); - return now.year == localDate.year && - now.month == localDate.month && - now.day == localDate.day; + return now.year == localDate.year && now.month == localDate.month && now.day == localDate.day; } } diff --git a/lib/features/menu/presentation/pages/menu_screen.dart b/lib/features/menu/presentation/pages/menu_screen.dart index 7e4c358a..8aa16842 100644 --- a/lib/features/menu/presentation/pages/menu_screen.dart +++ b/lib/features/menu/presentation/pages/menu_screen.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/const.dart'; import 'package:eatvio_app/core/theme/custom_text_style.dart'; import 'package:eatvio_app/core/token_storage.dart'; import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/core/utils/date_time_utils.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart'; @@ -160,7 +161,7 @@ class _AppInfoState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Версия приложения: $version ($buildNumber)', style: TextStyles.textXSSemibold.copyWith(color: appTheme.gray)), - if (buildDate != '') Text('Дата сборки: $buildDate', style: TextStyles.textXSSemibold.copyWith(color: appTheme.gray)), + if (buildDate != '') Text('Дата сборки: ${formatBuildDate(buildDate)}', style: TextStyles.textXSSemibold.copyWith(color: appTheme.gray)), ], ), ),