Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use en date format when locale not available #1261

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/utils/date.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import "package:intl/intl.dart";
import 'package:timeago/timeago.dart' as timeago;

class BreezDateUtils {
static final DateFormat _monthDateFormat = DateFormat.Md(Platform.localeName);
static final DateFormat _yearMonthDayFormat =
DateFormat.yMd(Platform.localeName);
static final localeName = Platform.localeName ?? "en";
static final DateFormat _monthDateFormat = DateFormat.Md(localeName);
static final DateFormat _yearMonthDayFormat = DateFormat.yMd(localeName);
static final DateFormat _yearMonthDayHourMinuteFormat =
DateFormat.yMd(Platform.localeName).add_jm();
DateFormat.yMd().add_jm();
static final DateFormat _yearMonthDayHourMinuteSecondFormat =
DateFormat.yMd(Platform.localeName).add_Hms();
static final DateFormat _hourMinuteDayFormat =
DateFormat.jm(Platform.localeName);
DateFormat.yMd(localeName).add_Hms();
static final DateFormat _hourMinuteDayFormat = DateFormat.jm(localeName);

static String formatMonthDate(DateTime d) => _monthDateFormat.format(d);
static String formatYearMonthDay(DateTime d) => _yearMonthDayFormat.format(d);
Expand All @@ -40,7 +39,8 @@ class BreezDateUtils {
}

static void setupLocales() {
timeago.setLocaleMessages('bg', timeago.EnMessages()); // TODO: add bg locale
timeago.setLocaleMessages(
'bg', timeago.EnMessages()); // TODO: add bg locale
timeago.setLocaleMessages('cs', timeago.CsMessages());
timeago.setLocaleMessages('de', timeago.DeMessages());
timeago.setLocaleMessages('el', timeago.GrMessages());
Expand All @@ -50,7 +50,8 @@ class BreezDateUtils {
timeago.setLocaleMessages('fr', timeago.FrMessages());
timeago.setLocaleMessages('it', timeago.ItMessages());
timeago.setLocaleMessages('pt', timeago.PtBrMessages());
timeago.setLocaleMessages('sk', timeago.EnMessages()); // TODO: add sk locale
timeago.setLocaleMessages(
'sk', timeago.EnMessages()); // TODO: add sk locale
timeago.setLocaleMessages('sv', timeago.SvMessages());
}
}