TF-1003 Fix select today as start date, can not receive vacation message
This commit is contained in:
@@ -13,7 +13,7 @@ extension DateTimeExtension on DateTime? {
|
|||||||
|
|
||||||
DateTime? applied(TimeOfDay? time) {
|
DateTime? applied(TimeOfDay? time) {
|
||||||
if (this != null && time != null) {
|
if (this != null && time != null) {
|
||||||
return DateTime.utc(this!.year, this!.month, this!.day, time.hour, time.minute);
|
return DateTime(this!.year, this!.month, this!.day, time.hour, time.minute);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-19
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||||
@@ -15,13 +14,13 @@ extension VacationResponseExtension on VacationResponse {
|
|||||||
status: isEnabled == true
|
status: isEnabled == true
|
||||||
? VacationResponderStatus.activated
|
? VacationResponderStatus.activated
|
||||||
: VacationResponderStatus.deactivated,
|
: VacationResponderStatus.deactivated,
|
||||||
startDate: fromDate?.value.toUtc(),
|
startDate: fromDate?.value.toLocal(),
|
||||||
startTime: fromDate?.value != null
|
startTime: fromDate?.value != null
|
||||||
? TimeOfDay.fromDateTime(fromDate!.value.toUtc())
|
? TimeOfDay.fromDateTime(fromDate!.value.toLocal())
|
||||||
: null,
|
: null,
|
||||||
endDate: toDate?.value.toUtc(),
|
endDate: toDate?.value.toLocal(),
|
||||||
endTime: toDate?.value != null
|
endTime: toDate?.value != null
|
||||||
? TimeOfDay.fromDateTime(toDate!.value.toUtc())
|
? TimeOfDay.fromDateTime(toDate!.value.toLocal())
|
||||||
: null,
|
: null,
|
||||||
messagePlainText: textBody,
|
messagePlainText: textBody,
|
||||||
messageHtmlText: htmlBody,
|
messageHtmlText: htmlBody,
|
||||||
@@ -36,10 +35,8 @@ extension VacationResponseExtension on VacationResponse {
|
|||||||
|
|
||||||
bool get vacationResponderIsReady {
|
bool get vacationResponderIsReady {
|
||||||
if (isEnabled == true) {
|
if (isEnabled == true) {
|
||||||
final currentDate = DateTime.now().toUtc();
|
final currentDate = DateTime.now();
|
||||||
log('VacationResponseExtension::vacationResponderEnabled(): currentDate: $currentDate');
|
final startDate = fromDate?.value.toLocal();
|
||||||
final startDate = fromDate?.value.toUtc();
|
|
||||||
log('VacationResponseExtension::vacationResponderEnabled(): startDate: $startDate');
|
|
||||||
if (startDate != null && (startDate.isBefore(currentDate) ||
|
if (startDate != null && (startDate.isBefore(currentDate) ||
|
||||||
startDate.isAtSameMomentAs(currentDate))) {
|
startDate.isAtSameMomentAs(currentDate))) {
|
||||||
return true;
|
return true;
|
||||||
@@ -52,10 +49,8 @@ extension VacationResponseExtension on VacationResponse {
|
|||||||
|
|
||||||
bool get vacationResponderIsWaiting {
|
bool get vacationResponderIsWaiting {
|
||||||
if (isEnabled == true) {
|
if (isEnabled == true) {
|
||||||
final currentDate = DateTime.now().toUtc();
|
final currentDate = DateTime.now();
|
||||||
log('VacationResponseExtension::vacationResponderIsWaiting(): currentDate: $currentDate');
|
final startDate = fromDate?.value.toLocal();
|
||||||
final startDate = fromDate?.value.toUtc();
|
|
||||||
log('VacationResponseExtension::vacationResponderIsWaiting(): startDate: $startDate');
|
|
||||||
if (startDate != null && startDate.isAfter(currentDate)) {
|
if (startDate != null && startDate.isAfter(currentDate)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -67,10 +62,8 @@ extension VacationResponseExtension on VacationResponse {
|
|||||||
|
|
||||||
bool get vacationResponderIsStopped {
|
bool get vacationResponderIsStopped {
|
||||||
if (isEnabled == true) {
|
if (isEnabled == true) {
|
||||||
final currentDate = DateTime.now().toUtc();
|
final currentDate = DateTime.now();
|
||||||
log('VacationResponseExtension::vacationResponderIsStopped(): currentDate: $currentDate');
|
final endDate = toDate?.value.toLocal();
|
||||||
final endDate = toDate?.value.toUtc();
|
|
||||||
log('VacationResponseExtension::vacationResponderIsStopped(): endDate: $endDate');
|
|
||||||
if (endDate != null && endDate.isBefore(currentDate)) {
|
if (endDate != null && endDate.isBefore(currentDate)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -103,12 +96,12 @@ extension VacationResponseExtension on VacationResponse {
|
|||||||
return AppLocalizations.of(context).yourVacationResponderIsEnabled;
|
return AppLocalizations.of(context).yourVacationResponderIsEnabled;
|
||||||
} else if (vacationResponderIsWaiting) {
|
} else if (vacationResponderIsWaiting) {
|
||||||
return AppLocalizations.of(context).messageEnableVacationResponderAutomatically(
|
return AppLocalizations.of(context).messageEnableVacationResponderAutomatically(
|
||||||
fromDate.formatDate(
|
fromDate.formatDateToLocal(
|
||||||
pattern: 'MMM d, y h:mm a',
|
pattern: 'MMM d, y h:mm a',
|
||||||
locale: Localizations.localeOf(context).toLanguageTag()));
|
locale: Localizations.localeOf(context).toLanguageTag()));
|
||||||
} else if (vacationResponderIsStopped) {
|
} else if (vacationResponderIsStopped) {
|
||||||
return AppLocalizations.of(context).messageDisableVacationResponderAutomatically(
|
return AppLocalizations.of(context).messageDisableVacationResponderAutomatically(
|
||||||
toDate.formatDate(
|
toDate.formatDateToLocal(
|
||||||
pattern: 'MMM d, y h:mm a',
|
pattern: 'MMM d, y h:mm a',
|
||||||
locale: Localizations.localeOf(context).toLanguageTag()));
|
locale: Localizations.localeOf(context).toLanguageTag()));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ extension VacationPresentationExtension on VacationPresentation {
|
|||||||
VacationResponse toVacationResponse() {
|
VacationResponse toVacationResponse() {
|
||||||
return VacationResponse(
|
return VacationResponse(
|
||||||
isEnabled: isEnabled,
|
isEnabled: isEnabled,
|
||||||
fromDate: fromDate != null ? UTCDate(fromDate!) : null,
|
fromDate: fromDate != null ? UTCDate(fromDate!.toUtc()) : null,
|
||||||
toDate: toDate != null ? UTCDate(toDate!) : null,
|
toDate: toDate != null ? UTCDate(toDate!.toUtc()) : null,
|
||||||
textBody: messagePlainText,
|
textBody: messagePlainText,
|
||||||
htmlBody: messageHtmlText,
|
htmlBody: messageHtmlText,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
|
|||||||
@@ -10,12 +10,4 @@ extension UTCDateExtension on UTCDate? {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String formatDate({String pattern = 'yMMMd', String locale = 'en_US'}) {
|
|
||||||
if (this != null) {
|
|
||||||
return DateFormat(pattern, locale).format(this!.value);
|
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user