forked from eatvio/eatvio_app
Merge pull request 'fix: Issue-618' (#654) from mso7nueh/eatvio_app:main into main
Reviewed-on: eatvio/eatvio_app#654
This commit is contained in:
@@ -3,11 +3,30 @@ import 'package:intl/intl.dart';
|
|||||||
|
|
||||||
const String dateTimeFormatPattern = 'dd/MM/yyyy';
|
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 {
|
extension DateTimeExtension on DateTime {
|
||||||
String format([
|
String format([String pattern = dateTimeFormatPattern, String? locale]) {
|
||||||
String pattern = dateTimeFormatPattern,
|
|
||||||
String? locale,
|
|
||||||
]) {
|
|
||||||
final localDate = isUtc ? toLocal() : this;
|
final localDate = isUtc ? toLocal() : this;
|
||||||
if (locale != null && locale.isNotEmpty) {
|
if (locale != null && locale.isNotEmpty) {
|
||||||
initializeDateFormatting(locale);
|
initializeDateFormatting(locale);
|
||||||
@@ -19,17 +38,13 @@ extension DateTimeExtension on DateTime {
|
|||||||
final localDate = isUtc ? toLocal() : this;
|
final localDate = isUtc ? toLocal() : this;
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final yesterday = DateTime(now.year, now.month, now.day).subtract(const Duration(days: 1));
|
final yesterday = DateTime(now.year, now.month, now.day).subtract(const Duration(days: 1));
|
||||||
return localDate.year == yesterday.year &&
|
return localDate.year == yesterday.year && localDate.month == yesterday.month && localDate.day == yesterday.day;
|
||||||
localDate.month == yesterday.month &&
|
|
||||||
localDate.day == yesterday.day;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isToday() {
|
bool isToday() {
|
||||||
final localDate = isUtc ? toLocal() : this;
|
final localDate = isUtc ? toLocal() : this;
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
return now.year == localDate.year &&
|
return now.year == localDate.year && now.month == localDate.month && now.day == localDate.day;
|
||||||
now.month == localDate.month &&
|
|
||||||
now.day == localDate.day;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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/theme/custom_text_style.dart';
|
||||||
import 'package:eatvio_app/core/token_storage.dart';
|
import 'package:eatvio_app/core/token_storage.dart';
|
||||||
import 'package:eatvio_app/core/utils/image_constant.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/locator_service.dart';
|
||||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||||
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart';
|
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/consultant_finances_screen.dart';
|
||||||
@@ -160,7 +161,7 @@ class _AppInfoState extends State<AppInfo> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('Версия приложения: $version ($buildNumber)', style: TextStyles.textXSSemibold.copyWith(color: appTheme.gray)),
|
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)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user