|
|
|
|
@ -4,7 +4,8 @@ import 'package:intl/intl.dart';
|
|
|
|
|
class DateUtil {
|
|
|
|
|
/// convert String To Date function
|
|
|
|
|
/// [date] String we want to convert
|
|
|
|
|
static DateTime convertStringToDate(String date) { // /Date(1585774800000+0300)/
|
|
|
|
|
static DateTime convertStringToDate(String date) {
|
|
|
|
|
// /Date(1585774800000+0300)/
|
|
|
|
|
if (date != null) {
|
|
|
|
|
const start = "/Date(";
|
|
|
|
|
const end = "+0300)";
|
|
|
|
|
@ -241,6 +242,25 @@ class DateUtil {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getWeekDayEnglish(int weekDay) {
|
|
|
|
|
switch (weekDay) {
|
|
|
|
|
case 1:
|
|
|
|
|
return "Monday";
|
|
|
|
|
case 2:
|
|
|
|
|
return "Tuesday";
|
|
|
|
|
case 3:
|
|
|
|
|
return "Wednesday";
|
|
|
|
|
case 4:
|
|
|
|
|
return "Thursday";
|
|
|
|
|
case 5:
|
|
|
|
|
return "Friday";
|
|
|
|
|
case 6:
|
|
|
|
|
return "Saturday ";
|
|
|
|
|
case 7:
|
|
|
|
|
return "Sunday";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// get data formatted like Apr 26,2020
|
|
|
|
|
/// [dateTime] convert DateTime to data formatted
|
|
|
|
|
static String getMonthDayYearDateFormatted(DateTime dateTime) {
|
|
|
|
|
@ -253,6 +273,7 @@ class DateUtil {
|
|
|
|
|
else
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// get data formatted like Apr 26,2020
|
|
|
|
|
/// [dateTime] convert DateTime to data formatted Arabic
|
|
|
|
|
static String getMonthDayYearDateFormattedAr(DateTime dateTime) {
|
|
|
|
|
@ -270,9 +291,12 @@ class DateUtil {
|
|
|
|
|
/// [dateTime] convert DateTime to date formatted
|
|
|
|
|
static String getWeekDayMonthDayYearDateFormatted(
|
|
|
|
|
DateTime dateTime, String lang) {
|
|
|
|
|
// print(dateTime);
|
|
|
|
|
// print(dateTime.weekday);
|
|
|
|
|
// print(dateTime.weekday.getDayOfWeekEnumValue.value);
|
|
|
|
|
if (dateTime != null)
|
|
|
|
|
return lang == 'en'
|
|
|
|
|
? getDay(dateTime.weekday.getDayOfWeekEnumValue) +
|
|
|
|
|
? getWeekDayEnglish(dateTime.weekday) +
|
|
|
|
|
", " +
|
|
|
|
|
getMonth(dateTime.month) +
|
|
|
|
|
" " +
|
|
|
|
|
@ -357,9 +381,8 @@ class DateUtil {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String getFormattedDate(DateTime dateTime, String formattedString){
|
|
|
|
|
return DateFormat(formattedString)
|
|
|
|
|
.format(dateTime);
|
|
|
|
|
static String getFormattedDate(DateTime dateTime, String formattedString) {
|
|
|
|
|
return DateFormat(formattedString).format(dateTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static convertISODateToJsonDate(String isoDate) {
|
|
|
|
|
|