Date formating issue #527

This commit is contained in:
Hillel Coren 2022-12-26 10:05:25 +02:00
parent 8b5a75008b
commit 241897dbc0
1 changed files with 6 additions and 2 deletions

View File

@ -421,6 +421,7 @@ String formatDate(String value, BuildContext context,
final state = StoreProvider.of<AppState>(context).state;
final CompanyEntity company = state.company;
var formattedValue = '';
if (showTime) {
String format;
@ -450,15 +451,18 @@ String formatDate(String value, BuildContext context,
final formatter = DateFormat(format, localeSelector(state));
final parsed = DateTime.tryParse(value.endsWith('Z') ? value : value + 'Z');
return parsed == null ? '' : formatter.format(parsed.toLocal());
formattedValue = parsed == null ? '' : formatter.format(parsed.toLocal());
} else {
final dateFormats = state.staticState.dateFormatMap;
final formatter = DateFormat(
dateFormats[company.settings.dateFormatId].format,
localeSelector(state));
final parsed = DateTime.tryParse(value);
return parsed == null ? '' : formatter.format(parsed);
formattedValue = parsed == null ? '' : formatter.format(parsed);
}
// Fix double periods in dates in foreign languages #527
return formattedValue.replaceFirst('..', '.');
}
String formatApiUrl(String url) {