cake_wallet/lib/utils/date_formatter.dart

24 lines
781 B
Dart
Raw Normal View History

2020-09-21 11:50:26 +00:00
import 'package:intl/intl.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/store/settings_store.dart';
class DateFormatter {
2020-10-22 15:11:52 +00:00
static String currentLocalFormat({bool hasTime = true}) {
2020-09-28 15:47:43 +00:00
final isUSA = getIt.get<SettingsStore>().languageCode.toLowerCase() == 'en';
2020-10-22 15:11:52 +00:00
final format =
isUSA ? usaStyleFormat(hasTime) : regularStyleFormat(hasTime);
2020-09-21 11:50:26 +00:00
return format;
}
2020-10-22 15:11:52 +00:00
static DateFormat withCurrentLocal({bool hasTime = true}) => DateFormat(
currentLocalFormat(hasTime: hasTime),
getIt.get<SettingsStore>().languageCode);
static String usaStyleFormat(bool hasTime) =>
hasTime ? 'yyyy.MM.dd, HH:mm' : 'yyyy.MM.dd';
static String regularStyleFormat(bool hasTime) =>
hasTime ? 'dd.MM.yyyy, HH:mm' : 'dd.MM.yyyy';
2020-09-21 11:50:26 +00:00
}