|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
|
|
class DateUtils {
|
|
|
|
|
|
|
|
|
|
static String convertDateToFormat(DateTime dateTime, String dateFormat) {
|
|
|
|
|
return DateFormat(dateFormat).format(dateTime);
|
|
|
|
|
}
|
|
|
|
@ -34,7 +33,8 @@ class DateUtils {
|
|
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String differenceBetweenDateAndCurrentInYearMonthDay(DateTime firstDate, BuildContext context) {
|
|
|
|
|
static String differenceBetweenDateAndCurrentInYearMonthDay(
|
|
|
|
|
DateTime firstDate, BuildContext context) {
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
|
// now = now.add(Duration(days: 400, minutes: 0));
|
|
|
|
|
var difference = firstDate.difference(now);
|
|
|
|
@ -54,13 +54,15 @@ class DateUtils {
|
|
|
|
|
return "$days ${TranslationBase.of(context).days}, $months ${TranslationBase.of(context).months}, $years ${TranslationBase.of(context).years}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String differenceBetweenDateAndCurrent(DateTime firstDate, BuildContext context) {
|
|
|
|
|
static String differenceBetweenDateAndCurrent(
|
|
|
|
|
DateTime firstDate, BuildContext context) {
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
|
// DateTime now = nows.add(Duration(days: 400, minutes: 25, hours: 0));
|
|
|
|
|
var difference = now.difference(firstDate);
|
|
|
|
|
|
|
|
|
|
int minutesInDays = difference.inMinutes;
|
|
|
|
|
int hoursInDays = minutesInDays ~/ 60; // ~/ : truncating division to make the result int
|
|
|
|
|
int hoursInDays =
|
|
|
|
|
minutesInDays ~/ 60; // ~/ : truncating division to make the result int
|
|
|
|
|
int minutes = minutesInDays % 60;
|
|
|
|
|
int days = hoursInDays ~/ 24;
|
|
|
|
|
int hours = hoursInDays % 24;
|
|
|
|
@ -70,7 +72,8 @@ class DateUtils {
|
|
|
|
|
return "$days ${TranslationBase.of(context).days}, $hours ${TranslationBase.of(context).hr}, $minutes ${TranslationBase.of(context).min}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String differenceBetweenServerDateAndCurrent(String str, BuildContext context) {
|
|
|
|
|
static String differenceBetweenServerDateAndCurrent(
|
|
|
|
|
String str, BuildContext context) {
|
|
|
|
|
const start = "/Date(";
|
|
|
|
|
|
|
|
|
|
const end = "+0300)";
|
|
|
|
@ -217,7 +220,8 @@ class DateUtils {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)";
|
|
|
|
@ -276,4 +280,3 @@ class DateUtils {
|
|
|
|
|
return "$years ${TranslationBase.of(context).years} $months ${TranslationBase.of(context).months} $days ${TranslationBase.of(context).days}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|