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 {
|
2022-09-02 13:10:54 +00:00
|
|
|
static String currentLocalFormat({bool hasTime = true, bool reverse = false}) {
|
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 =
|
2022-09-02 13:10:54 +00:00
|
|
|
isUSA ? usaStyleFormat(hasTime, reverse) : regularStyleFormat(hasTime, reverse);
|
2020-09-21 11:50:26 +00:00
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2022-09-02 13:10:54 +00:00
|
|
|
static DateFormat withCurrentLocal({bool hasTime = true, bool reverse = false}) => DateFormat(
|
|
|
|
currentLocalFormat(hasTime: hasTime, reverse: reverse),
|
2020-10-22 15:11:52 +00:00
|
|
|
getIt.get<SettingsStore>().languageCode);
|
|
|
|
|
2022-09-02 13:10:54 +00:00
|
|
|
static String usaStyleFormat(bool hasTime, bool reverse) =>
|
|
|
|
hasTime ? (reverse ? 'HH:mm yyyy.MM.dd' : 'yyyy.MM.dd, HH:mm') : 'yyyy.MM.dd';
|
2020-10-22 15:11:52 +00:00
|
|
|
|
2022-09-02 13:10:54 +00:00
|
|
|
static String regularStyleFormat(bool hasTime, bool reverse) =>
|
|
|
|
hasTime ? (reverse ? 'HH:mm dd.MM.yyyy' : 'dd.MM.yyyy, HH:mm') : 'dd.MM.yyyy';
|
2020-09-21 11:50:26 +00:00
|
|
|
}
|