fix date style issues with changing lang

fatima_dev
Fatimah.Alshammari 16 hours ago
parent 84510a1272
commit 21bf1ff655

@ -159,10 +159,55 @@ extension FormatDate on String {
return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a', "en_US").format(DateFormat('hh:mm:ss', "en_US").parse(time))}";
}
String toFormattedDateWithoutTime() {
// String toFormattedDateWithoutTime() {
// String date = split("T")[0];
// var dates = date.split("-");
// return "${dates[2]} ${getMonth(int.parse(dates[1]))}, ${dates[0]}";
// }
String toFormattedDateWithoutTime({bool isArabic = false}) {
String date = split("T")[0];
var dates = date.split("-");
return "${dates[2]} ${getMonth(int.parse(dates[1]))}, ${dates[0]}";
final monthNumber = int.parse(dates[1]);
final monthsEn = [
'',
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
final monthsAr = [
'',
'يناير',
'فبراير',
'مارس',
'أبريل',
'مايو',
'يونيو',
'يوليو',
'أغسطس',
'سبتمبر',
'أكتوبر',
'نوفمبر',
'ديسمبر',
];
final month = isArabic
? monthsAr[monthNumber]
: monthsEn[monthNumber];
return "${dates[2]} $month, ${dates[0]}";
}
String toLocalizedFormattedDateWithoutTime(BuildContext context) {

@ -294,7 +294,7 @@ class AppointmentDetailView extends StatelessWidget {
fit: BoxFit.fill,
),
5.width,
"${appointmentListModel.duration ?? ""} ${appointmentListModel.appointmentDate!.toFormattedDateWithoutTime()}".toText(fontSize: 12, isBold: true, color: MyColors.lightTextColor),
"${appointmentListModel.duration ?? ""} ${appointmentListModel.appointmentDate!.toFormattedDateWithoutTime( isArabic: context.locale.languageCode == 'ar',)}".toText(fontSize: 12, isBold: true, color: MyColors.lightTextColor),
],
),
13.height,

@ -135,7 +135,7 @@ class AppointmentHomeTileWidget extends StatelessWidget {
if (appointmentListModel.appointmentServicesList!.length > 1) {
servicesList.add(
showServices("+ ${appointmentListModel.appointmentServicesList!.length - 1} More", "", isMoreText: true),
showServices("+ ${appointmentListModel.appointmentServicesList!.length - 1} ${ LocaleKeys.more.tr() }", "", isMoreText: true),
);
}
return servicesList;
@ -329,7 +329,7 @@ class AppointmentFragmentTileWidget extends StatelessWidget {
children: [
MyAssets.miniClock.buildSvg(height: 12),
2.width,
" ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}"
" ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime( isArabic: AppState().isArabic(context),)}"
.toText(color: MyColors.lightTextColor, fontSize: 12, letterSpacing: -0.48, height: 19 / 12),
],
),

Loading…
Cancel
Save