From 1845f2d7cba6c7dd9d3a88d72eadab9a5389c4cd Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 17 Nov 2023 09:45:56 +0200 Subject: [PATCH] date value object toString, deprecate getString --- application/Espo/Classes/Cleanup/Exports.php | 2 +- .../Espo/Classes/Cleanup/MassActions.php | 2 +- .../Cleanup/PasswordChangeRequests.php | 2 +- .../Espo/Classes/Cleanup/Subscribers.php | 2 +- .../Event/BeforeUpdatePreserveDuration.php | 4 +- .../PrimaryFilters/Actual.php | 2 +- .../Core/Authentication/Oidc/KeysProvider.php | 2 +- .../Authentication/TwoFactor/Email/Util.php | 2 +- .../Authentication/TwoFactor/Sms/Util.php | 2 +- application/Espo/Core/Field/Date.php | 41 +++++++++-- .../Field/Date/DateAttributeExtractor.php | 2 +- application/Espo/Core/Field/DateTime.php | 41 +++++++++-- .../DateTime/DateTimeAttributeExtractor.php | 2 +- .../Espo/Core/Field/DateTime/DateTimeable.php | 2 +- .../Espo/Core/Field/DateTimeOptional.php | 71 +++++++++++++------ .../DateTimeOptionalAttributeExtractor.php | 4 +- .../WorkingTimeGroup/AddWorkingDaysType.php | 6 +- .../FindClosestWorkingTimeType.php | 2 +- .../Espo/Core/Mail/Account/FetchData.php | 2 +- .../Espo/Core/Mail/Account/Fetcher.php | 4 +- .../Mail/Account/Storage/LaminasStorage.php | 2 +- application/Espo/Core/Mail/Sender.php | 2 +- .../Select/Where/ItemGeneralConverter.php | 66 ++++++++--------- application/Espo/Entities/AuthToken.php | 2 +- application/Espo/Entities/Sms.php | 2 +- .../Crm/Tools/Calendar/Items/BusyRange.php | 4 +- .../Crm/Tools/Calendar/Items/Event.php | 4 +- .../Tools/Calendar/Items/NonWorkingRange.php | 4 +- .../Crm/Tools/Calendar/Items/WorkingRange.php | 4 +- .../Modules/Crm/Tools/Calendar/Service.php | 38 +++++----- .../Modules/Crm/Tools/Campaign/LogService.php | 14 ++-- .../Tools/Opportunity/Report/ByLeadSource.php | 8 +-- .../Crm/Tools/Opportunity/Report/ByStage.php | 8 +-- .../Tools/Opportunity/Report/SalesByMonth.php | 8 +-- .../Opportunity/Report/SalesPipeline.php | 8 +-- .../Tools/Attachment/Jobs/MoveToStorage.php | 2 +- .../Export/Format/Xlsx/OpenSpoutProcessor.php | 4 +- .../Format/Xlsx/PhpSpreadsheetProcessor.php | 4 +- .../Espo/Tools/LeadCapture/CaptureService.php | 2 +- .../Tools/LeadCapture/ConfirmationSender.php | 4 +- application/Espo/Tools/Stream/Service.php | 4 +- .../UserSecurity/Password/RecoveryService.php | 4 +- .../Espo/Tools/WorkingTime/Extractor.php | 14 ++-- .../Espo/Tools/WorkingTime/GlobalCalendar.php | 6 +- .../Espo/Tools/WorkingTime/TeamCalendar.php | 6 +- .../Espo/Tools/WorkingTime/UserCalendar.php | 12 ++-- .../Espo/Core/Formula/FormulaTest.php | 16 ++--- tests/integration/Espo/Record/LinkTest.php | 6 +- tests/integration/Espo/User/AclTest.php | 6 +- tests/unit/Espo/Core/Field/Date/DateTest.php | 14 ++-- .../Espo/Core/Field/DateTime/DateTimeTest.php | 30 ++++---- .../DateTimeOptionalDateTest.php | 18 ++--- .../DateTimeOptional/DateTimeOptionalTest.php | 34 ++++----- .../Espo/Core/Mail/Account/FetchDataTest.php | 2 +- 54 files changed, 320 insertions(+), 239 deletions(-) diff --git a/application/Espo/Classes/Cleanup/Exports.php b/application/Espo/Classes/Cleanup/Exports.php index c9a0095ac3..818a5815d9 100644 --- a/application/Espo/Classes/Cleanup/Exports.php +++ b/application/Espo/Classes/Cleanup/Exports.php @@ -57,7 +57,7 @@ class Exports implements Cleanup $before = DateTime::createNow() ->modify($period) - ->getString(); + ->toString(); $delete = $this->entityManager ->getQueryBuilder() diff --git a/application/Espo/Classes/Cleanup/MassActions.php b/application/Espo/Classes/Cleanup/MassActions.php index 7673117590..454bc7995e 100644 --- a/application/Espo/Classes/Cleanup/MassActions.php +++ b/application/Espo/Classes/Cleanup/MassActions.php @@ -55,7 +55,7 @@ class MassActions implements Cleanup $before = DateTime::createNow() ->modify($period) - ->getString(); + ->toString(); $delete = $this->entityManager ->getQueryBuilder() diff --git a/application/Espo/Classes/Cleanup/PasswordChangeRequests.php b/application/Espo/Classes/Cleanup/PasswordChangeRequests.php index 1a2c6a2650..a7f64603bb 100644 --- a/application/Espo/Classes/Cleanup/PasswordChangeRequests.php +++ b/application/Espo/Classes/Cleanup/PasswordChangeRequests.php @@ -56,7 +56,7 @@ class PasswordChangeRequests implements Cleanup $before = DateTime::createNow() ->modify($period) - ->getString(); + ->toString(); $delete = $this->entityManager ->getQueryBuilder() diff --git a/application/Espo/Classes/Cleanup/Subscribers.php b/application/Espo/Classes/Cleanup/Subscribers.php index b850e6351a..b2fa748788 100644 --- a/application/Espo/Classes/Cleanup/Subscribers.php +++ b/application/Espo/Classes/Cleanup/Subscribers.php @@ -122,7 +122,7 @@ class Subscribers implements Cleanup ), Cond::less( Cond::column('entity.' . $dateField), - $before->getString() + $before->toString() ), Cond::in( Cond::column('entity.' . $statusField), diff --git a/application/Espo/Classes/RecordHooks/Event/BeforeUpdatePreserveDuration.php b/application/Espo/Classes/RecordHooks/Event/BeforeUpdatePreserveDuration.php index bf06391c30..34919c79dc 100644 --- a/application/Espo/Classes/RecordHooks/Event/BeforeUpdatePreserveDuration.php +++ b/application/Espo/Classes/RecordHooks/Event/BeforeUpdatePreserveDuration.php @@ -93,7 +93,7 @@ class BeforeUpdatePreserveDuration implements UpdateHook $dateEndModified = $dateStart->add($diff); - $entity->set('dateEnd', $dateEndModified->getString()); + $entity->set('dateEnd', $dateEndModified->toString()); } private function processDate(Entity $entity): void @@ -114,6 +114,6 @@ class BeforeUpdatePreserveDuration implements UpdateHook $dateEndModified = $dateStart->add($diff); - $entity->set('dateEndDate', $dateEndModified->getString()); + $entity->set('dateEndDate', $dateEndModified->toString()); } } diff --git a/application/Espo/Classes/Select/WorkingTimeRange/PrimaryFilters/Actual.php b/application/Espo/Classes/Select/WorkingTimeRange/PrimaryFilters/Actual.php index 17bf3acb67..0ea55326bf 100644 --- a/application/Espo/Classes/Select/WorkingTimeRange/PrimaryFilters/Actual.php +++ b/application/Espo/Classes/Select/WorkingTimeRange/PrimaryFilters/Actual.php @@ -41,7 +41,7 @@ class Actual implements Filter $queryBuilder->where( Expression::greaterOrEqual( Expression::column('dateEnd'), - Date::createToday()->getString() + Date::createToday()->toString() ) ); } diff --git a/application/Espo/Core/Authentication/Oidc/KeysProvider.php b/application/Espo/Core/Authentication/Oidc/KeysProvider.php index 4a76348205..c5c957229a 100644 --- a/application/Espo/Core/Authentication/Oidc/KeysProvider.php +++ b/application/Espo/Core/Authentication/Oidc/KeysProvider.php @@ -172,7 +172,7 @@ class KeysProvider $period = '-' . $this->configDataProvider->getJwksCachePeriod(); - if ($timestamp < DateTime::createNow()->modify($period)->getTimestamp()) { + if ($timestamp < DateTime::createNow()->modify($period)->toTimestamp()) { return null; } diff --git a/application/Espo/Core/Authentication/TwoFactor/Email/Util.php b/application/Espo/Core/Authentication/TwoFactor/Email/Util.php index 9cdb3890b3..e4165fe57c 100644 --- a/application/Espo/Core/Authentication/TwoFactor/Email/Util.php +++ b/application/Espo/Core/Authentication/TwoFactor/Email/Util.php @@ -244,7 +244,7 @@ class Util $from = DateTime::createNow() ->modify('-' . $period) - ->getString(); + ->toString(); $count = $this->entityManager ->getRDBRepository(TwoFactorCode::ENTITY_TYPE) diff --git a/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php b/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php index f700cbc8f9..63041c45a9 100644 --- a/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php +++ b/application/Espo/Core/Authentication/TwoFactor/Sms/Util.php @@ -239,7 +239,7 @@ class Util $from = DateTime::createNow() ->modify('-' . $period) - ->getString(); + ->toString(); $count = $this->entityManager ->getRDBRepository(TwoFactorCode::ENTITY_TYPE) diff --git a/application/Espo/Core/Field/Date.php b/application/Espo/Core/Field/Date.php index 37ca25ad84..5cb005ead4 100644 --- a/application/Espo/Core/Field/Date.php +++ b/application/Espo/Core/Field/Date.php @@ -77,7 +77,7 @@ class Date implements DateTimeable /** * Get a string value in `Y-m-d` format. */ - public function getString(): string + public function toString(): string { return $this->value; } @@ -85,7 +85,7 @@ class Date implements DateTimeable /** * Get DateTimeImmutable. */ - public function getDateTime(): DateTimeImmutable + public function toDateTime(): DateTimeImmutable { return $this->dateTime; } @@ -93,7 +93,7 @@ class Date implements DateTimeable /** * Get a timestamp. */ - public function getTimestamp(): int + public function toTimestamp(): int { return $this->dateTime->getTimestamp(); } @@ -200,7 +200,7 @@ class Date implements DateTimeable */ public function diff(DateTimeable $other): DateInterval { - return $this->getDateTime()->diff($other->getDateTime()); + return $this->toDateTime()->diff($other->toDateTime()); } /** @@ -208,7 +208,7 @@ class Date implements DateTimeable */ public function isGreaterThan(DateTimeable $other): bool { - return $this->getDateTime() > $other->getDateTime(); + return $this->toDateTime() > $other->toDateTime(); } /** @@ -216,7 +216,7 @@ class Date implements DateTimeable */ public function isLessThan(DateTimeable $other): bool { - return $this->getDateTime() < $other->getDateTime(); + return $this->toDateTime() < $other->toDateTime(); } /** @@ -224,7 +224,7 @@ class Date implements DateTimeable */ public function isEqualTo(DateTimeable $other): bool { - return $this->getDateTime() == $other->getDateTime(); + return $this->toDateTime() == $other->toDateTime(); } /** @@ -258,4 +258,31 @@ class Date implements DateTimeable return new self($value); } + + /** + * @deprecated As of v8.1. Use `toString` instead. + * @todo Remove in v10.0. + */ + public function getString(): string + { + return $this->toString(); + } + + /** + * @deprecated As of v8.1. Use `toDateTime` instead. + * @todo Remove in v10.0. + */ + public function getDateTime(): DateTimeImmutable + { + return $this->toDateTime(); + } + + /** + * @deprecated As of v8.1. Use `getTimestamp` instead. + * @todo Remove in v10.0. + */ + public function getTimestamp(): int + { + return $this->toTimestamp(); + } } diff --git a/application/Espo/Core/Field/Date/DateAttributeExtractor.php b/application/Espo/Core/Field/Date/DateAttributeExtractor.php index e8f34cfc14..a2180b9e98 100644 --- a/application/Espo/Core/Field/Date/DateAttributeExtractor.php +++ b/application/Espo/Core/Field/Date/DateAttributeExtractor.php @@ -51,7 +51,7 @@ class DateAttributeExtractor implements AttributeExtractor } return (object) [ - $field => $value->getString(), + $field => $value->toString(), ]; } diff --git a/application/Espo/Core/Field/DateTime.php b/application/Espo/Core/Field/DateTime.php index 0dcd9daf13..8095a3df96 100644 --- a/application/Espo/Core/Field/DateTime.php +++ b/application/Espo/Core/Field/DateTime.php @@ -79,7 +79,7 @@ class DateTime implements DateTimeable /** * Get a string value in `Y-m-d H:i:s` format. */ - public function getString(): string + public function toString(): string { return $this->value; } @@ -87,7 +87,7 @@ class DateTime implements DateTimeable /** * Get DateTimeImmutable. */ - public function getDateTime(): DateTimeImmutable + public function toDateTime(): DateTimeImmutable { return $this->dateTime; } @@ -95,7 +95,7 @@ class DateTime implements DateTimeable /** * Get a timestamp. */ - public function getTimestamp(): int + public function toTimestamp(): int { return $this->dateTime->getTimestamp(); } @@ -266,7 +266,7 @@ class DateTime implements DateTimeable */ public function diff(DateTimeable $other): DateInterval { - return $this->getDateTime()->diff($other->getDateTime()); + return $this->toDateTime()->diff($other->toDateTime()); } /** @@ -298,7 +298,7 @@ class DateTime implements DateTimeable */ public function isGreaterThan(DateTimeable $other): bool { - return $this->getDateTime() > $other->getDateTime(); + return $this->toDateTime() > $other->toDateTime(); } /** @@ -306,7 +306,7 @@ class DateTime implements DateTimeable */ public function isLessThan(DateTimeable $other): bool { - return $this->getDateTime() < $other->getDateTime(); + return $this->toDateTime() < $other->toDateTime(); } /** @@ -314,7 +314,7 @@ class DateTime implements DateTimeable */ public function isEqualTo(DateTimeable $other): bool { - return $this->getDateTime() == $other->getDateTime(); + return $this->toDateTime() == $other->toDateTime(); } /** @@ -365,4 +365,31 @@ class DateTime implements DateTimeable return $obj; } + + /** + * @deprecated As of v8.1. Use `toString` instead. + * @todo Remove in v10.0. + */ + public function getString(): string + { + return $this->toString(); + } + + /** + * @deprecated As of v8.1. Use `toDateTime` instead. + * @todo Remove in v10.0. + */ + public function getDateTime(): DateTimeImmutable + { + return $this->toDateTime(); + } + + /** + * @deprecated As of v8.1. Use `getTimestamp` instead. + * @todo Remove in v10.0. + */ + public function getTimestamp(): int + { + return $this->toTimestamp(); + } } diff --git a/application/Espo/Core/Field/DateTime/DateTimeAttributeExtractor.php b/application/Espo/Core/Field/DateTime/DateTimeAttributeExtractor.php index 9c4a094580..f67c39dc00 100644 --- a/application/Espo/Core/Field/DateTime/DateTimeAttributeExtractor.php +++ b/application/Espo/Core/Field/DateTime/DateTimeAttributeExtractor.php @@ -51,7 +51,7 @@ class DateTimeAttributeExtractor implements AttributeExtractor } return (object) [ - $field => $value->getString(), + $field => $value->toString(), ]; } diff --git a/application/Espo/Core/Field/DateTime/DateTimeable.php b/application/Espo/Core/Field/DateTime/DateTimeable.php index bc5efa9765..4503d71100 100644 --- a/application/Espo/Core/Field/DateTime/DateTimeable.php +++ b/application/Espo/Core/Field/DateTime/DateTimeable.php @@ -33,5 +33,5 @@ use DateTimeImmutable; interface DateTimeable { - public function getDateTime(): DateTimeImmutable; + public function toDateTime(): DateTimeImmutable; } diff --git a/application/Espo/Core/Field/DateTimeOptional.php b/application/Espo/Core/Field/DateTimeOptional.php index bc94374bf6..2f4f103b40 100644 --- a/application/Espo/Core/Field/DateTimeOptional.php +++ b/application/Espo/Core/Field/DateTimeOptional.php @@ -83,25 +83,25 @@ class DateTimeOptional implements DateTimeable /** * Get a string value in `Y-m-d H:i:s` format. */ - public function getString(): string + public function toString(): string { - return $this->getActualValue()->getString(); + return $this->getActualValue()->toString(); } /** * Get DateTimeImmutable. */ - public function getDateTime(): DateTimeImmutable + public function toDateTime(): DateTimeImmutable { - return $this->getActualValue()->getDateTime(); + return $this->getActualValue()->toDateTime(); } /** * Get a timestamp. */ - public function getTimestamp(): int + public function toTimestamp(): int { - return $this->getActualValue()->getDateTime()->getTimestamp(); + return $this->getActualValue()->toDateTime()->getTimestamp(); } /** @@ -194,7 +194,7 @@ class DateTimeOptional implements DateTimeable */ public function getTimezone(): DateTimeZone { - return $this->getDateTime()->getTimezone(); + return $this->toDateTime()->getTimezone(); } /** @@ -212,7 +212,7 @@ class DateTimeOptional implements DateTimeable public function withTimezone(DateTimeZone $timezone): self { if ($this->isAllDay()) { - $dateTime = $this->getActualValue()->getDateTime()->setTimezone($timezone); + $dateTime = $this->getActualValue()->toDateTime()->setTimezone($timezone); return self::fromDateTime($dateTime); } @@ -220,7 +220,7 @@ class DateTimeOptional implements DateTimeable /** @var DateTime $value */ $value = $this->getActualValue(); - $dateTime = $value->withTimezone($timezone)->getDateTime(); + $dateTime = $value->withTimezone($timezone)->toDateTime(); return self::fromDateTime($dateTime); } @@ -231,10 +231,10 @@ class DateTimeOptional implements DateTimeable public function withTime(?int $hour, ?int $minute, ?int $second = 0): self { if ($this->isAllDay()) { - $dateTime = DateTime::fromDateTime($this->getActualValue()->getDateTime()) + $dateTime = DateTime::fromDateTime($this->getActualValue()->toDateTime()) ->withTime($hour, $minute, $second); - return self::fromDateTime($dateTime->getDateTime()); + return self::fromDateTime($dateTime->toDateTime()); } /** @var DateTime $value */ @@ -242,7 +242,7 @@ class DateTimeOptional implements DateTimeable $dateTime = $value->withTime($hour, $minute, $second); - return self::fromDateTime($dateTime->getDateTime()); + return self::fromDateTime($dateTime->toDateTime()); } /** @@ -254,14 +254,14 @@ class DateTimeOptional implements DateTimeable assert($this->dateValue !== null); return self::fromDateTimeAllDay( - $this->dateValue->modify($modifier)->getDateTime() + $this->dateValue->modify($modifier)->toDateTime() ); } assert($this->dateTimeValue !== null); return self::fromDateTime( - $this->dateTimeValue->modify($modifier)->getDateTime() + $this->dateTimeValue->modify($modifier)->toDateTime() ); } @@ -274,14 +274,14 @@ class DateTimeOptional implements DateTimeable assert($this->dateValue !== null); return self::fromDateTimeAllDay( - $this->dateValue->add($interval)->getDateTime() + $this->dateValue->add($interval)->toDateTime() ); } assert($this->dateTimeValue !== null); return self::fromDateTime( - $this->dateTimeValue->add($interval)->getDateTime() + $this->dateTimeValue->add($interval)->toDateTime() ); } @@ -294,14 +294,14 @@ class DateTimeOptional implements DateTimeable assert($this->dateValue !== null); return self::fromDateTimeAllDay( - $this->dateValue->subtract($interval)->getDateTime() + $this->dateValue->subtract($interval)->toDateTime() ); } assert($this->dateTimeValue !== null); return self::fromDateTime( - $this->dateTimeValue->subtract($interval)->getDateTime() + $this->dateTimeValue->subtract($interval)->toDateTime() ); } @@ -370,7 +370,7 @@ class DateTimeOptional implements DateTimeable */ public function diff(DateTimeable $other): DateInterval { - return $this->getDateTime()->diff($other->getDateTime()); + return $this->toDateTime()->diff($other->toDateTime()); } /** @@ -378,7 +378,7 @@ class DateTimeOptional implements DateTimeable */ public function isGreaterThan(DateTimeable $other): bool { - return $this->getDateTime() > $other->getDateTime(); + return $this->toDateTime() > $other->toDateTime(); } /** @@ -386,7 +386,7 @@ class DateTimeOptional implements DateTimeable */ public function isLessThan(DateTimeable $other): bool { - return $this->getDateTime() < $other->getDateTime(); + return $this->toDateTime() < $other->toDateTime(); } /** @@ -394,7 +394,7 @@ class DateTimeOptional implements DateTimeable */ public function isEqualTo(DateTimeable $other): bool { - return $this->getDateTime() == $other->getDateTime(); + return $this->toDateTime() == $other->toDateTime(); } /** @@ -484,4 +484,31 @@ class DateTimeOptional implements DateTimeable return false; } + + /** + * @deprecated As of v8.1. Use `toString` instead. + * @todo Remove in v10.0. + */ + public function getString(): string + { + return $this->toString(); + } + + /** + * @deprecated As of v8.1. Use `toDateTime` instead. + * @todo Remove in v10.0. + */ + public function getDateTime(): DateTimeImmutable + { + return $this->toDateTime(); + } + + /** + * @deprecated As of v8.1. Use `getTimestamp` instead. + * @todo Remove in v10.0. + */ + public function getTimestamp(): int + { + return $this->toTimestamp(); + } } diff --git a/application/Espo/Core/Field/DateTimeOptional/DateTimeOptionalAttributeExtractor.php b/application/Espo/Core/Field/DateTimeOptional/DateTimeOptionalAttributeExtractor.php index 9e840e5de9..46973661ee 100644 --- a/application/Espo/Core/Field/DateTimeOptional/DateTimeOptionalAttributeExtractor.php +++ b/application/Espo/Core/Field/DateTimeOptional/DateTimeOptionalAttributeExtractor.php @@ -52,13 +52,13 @@ class DateTimeOptionalAttributeExtractor implements AttributeExtractor if ($value->isAllDay()) { return (object) [ - $field . 'Date' => $value->getString(), + $field . 'Date' => $value->toString(), $field => null, ]; } return (object) [ - $field => $value->getString(), + $field => $value->toString(), $field . 'Date' => null, ]; } diff --git a/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/AddWorkingDaysType.php b/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/AddWorkingDaysType.php index bf380eea1c..c6a092d64a 100644 --- a/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/AddWorkingDaysType.php +++ b/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/AddWorkingDaysType.php @@ -74,7 +74,7 @@ class AddWorkingDaysType extends Base $dateTime = $dateTime->withTimezone($calendar->getTimezone()); } - $dateTime = DateTime::fromDateTime($dateTime->getDateTime()); + $dateTime = DateTime::fromDateTime($dateTime->toDateTime()); $result = $this->createCalendarUtility($calendar)->addWorkingDays($dateTime, $days); @@ -83,9 +83,9 @@ class AddWorkingDaysType extends Base } if ($isAllDay) { - return $result->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT); + return $result->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT); } - return $result->getString(); + return $result->toString(); } } diff --git a/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/FindClosestWorkingTimeType.php b/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/FindClosestWorkingTimeType.php index 4007e791ac..3cf9d23454 100644 --- a/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/FindClosestWorkingTimeType.php +++ b/application/Espo/Core/Formula/Functions/ExtGroup/WorkingTimeGroup/FindClosestWorkingTimeType.php @@ -66,6 +66,6 @@ class FindClosestWorkingTimeType extends Base return null; } - return $result->getString(); + return $result->toString(); } } diff --git a/application/Espo/Core/Mail/Account/FetchData.php b/application/Espo/Core/Mail/Account/FetchData.php index 441c4b2130..696218af3f 100644 --- a/application/Espo/Core/Mail/Account/FetchData.php +++ b/application/Espo/Core/Mail/Account/FetchData.php @@ -105,7 +105,7 @@ class FetchData return; } - $this->data->lastDate->$folder = $lastDate->getString(); + $this->data->lastDate->$folder = $lastDate->toString(); } public function setForceByDate(string $folder, bool $forceByDate): void diff --git a/application/Espo/Core/Mail/Account/Fetcher.php b/application/Espo/Core/Mail/Account/Fetcher.php index c4f237b877..8254b36ea8 100644 --- a/application/Espo/Core/Mail/Account/Fetcher.php +++ b/application/Espo/Core/Mail/Account/Fetcher.php @@ -170,7 +170,7 @@ class Fetcher if ($email && $email->getDateSent()) { $lastDate = $email->getDateSent(); - if ($lastDate->getTimestamp() >= (new DateTime())->getTimestamp()) { + if ($lastDate->toTimestamp() >= (new DateTime())->getTimestamp()) { $lastDate = DateTimeField::createNow(); } } @@ -237,7 +237,7 @@ class Fetcher throw new Error("{$account->getEntityType()} {$account->getId()}, no fetch-since."); } - $fetchSince = $account->getFetchSince()->getDateTime(); + $fetchSince = $account->getFetchSince()->toDateTime(); return $storage->getIdsSinceDate( DateTimeField::fromDateTime($fetchSince) diff --git a/application/Espo/Core/Mail/Account/Storage/LaminasStorage.php b/application/Espo/Core/Mail/Account/Storage/LaminasStorage.php index a096427a31..b7be0dfa51 100644 --- a/application/Espo/Core/Mail/Account/Storage/LaminasStorage.php +++ b/application/Espo/Core/Mail/Account/Storage/LaminasStorage.php @@ -79,7 +79,7 @@ class LaminasStorage implements Storage public function getIdsSinceDate(DateTime $since): array { return $this->imap->getIdsSinceDate( - $since->getDateTime()->format('d-M-Y') + $since->toDateTime()->format('d-M-Y') ); } diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index fb5f57472c..dd3e6d0212 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -598,7 +598,7 @@ class Sender $this->transport->send($message); $email->setStatus(Email::STATUS_SENT); - $email->set('dateSent', DateTime::createNow()->getString()); + $email->set('dateSent', DateTime::createNow()->toString()); } catch (Exception $e) { /** @noinspection PhpDeprecationInspection */ diff --git a/application/Espo/Core/Select/Where/ItemGeneralConverter.php b/application/Espo/Core/Select/Where/ItemGeneralConverter.php index b068775eda..bc3fa4b6a4 100644 --- a/application/Espo/Core/Select/Where/ItemGeneralConverter.php +++ b/application/Espo/Core/Select/Where/ItemGeneralConverter.php @@ -959,7 +959,7 @@ class ItemGeneralConverter implements ItemConverter ->withTimezone($this->getSystemTimeZone()); return [ - $attribute . '=' => $today->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '=' => $today->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ]; } @@ -972,7 +972,7 @@ class ItemGeneralConverter implements ItemConverter ->withTimezone($this->getSystemTimeZone()); return [ - $attribute . '<' => $today->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $today->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ]; } @@ -985,7 +985,7 @@ class ItemGeneralConverter implements ItemConverter ->withTimezone($this->getSystemTimeZone()); return [ - $attribute . '>' => $today->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>' => $today->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ]; } @@ -1001,8 +1001,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<=' => $today->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<=' => $today->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1022,8 +1022,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<=' => $today->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<=' => $today->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1043,8 +1043,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $today->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<=' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $today->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<=' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1062,7 +1062,7 @@ class ItemGeneralConverter implements ItemConverter ->addDays(- $number); return [ - $attribute . '<' => $date->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $date->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ]; } @@ -1079,7 +1079,7 @@ class ItemGeneralConverter implements ItemConverter ->addDays($number); return [ - $attribute . '>' => $date->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>' => $date->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ]; } @@ -1096,8 +1096,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1115,8 +1115,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1134,8 +1134,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1158,8 +1158,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1189,8 +1189,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1208,8 +1208,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1227,8 +1227,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1255,8 +1255,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1284,8 +1284,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1311,8 +1311,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } @@ -1339,8 +1339,8 @@ class ItemGeneralConverter implements ItemConverter return [ 'AND' => [ - $attribute . '>=' => $from->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), - $attribute . '<' => $to->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '>=' => $from->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), + $attribute . '<' => $to->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_FORMAT), ] ]; } diff --git a/application/Espo/Entities/AuthToken.php b/application/Espo/Entities/AuthToken.php index c62cc8b48c..23118243ea 100644 --- a/application/Espo/Entities/AuthToken.php +++ b/application/Espo/Entities/AuthToken.php @@ -118,7 +118,7 @@ class AuthToken extends BaseEntity implements AuthTokenInterface public function setLastAccessNow(): self { - $this->set('lastAccess', DateTime::createNow()->getString()); + $this->set('lastAccess', DateTime::createNow()->toString()); return $this; } diff --git a/application/Espo/Entities/Sms.php b/application/Espo/Entities/Sms.php index f436c36431..296bc54f05 100644 --- a/application/Espo/Entities/Sms.php +++ b/application/Espo/Entities/Sms.php @@ -132,7 +132,7 @@ class Sms extends Entity implements SmsInterface $this->set('status', Sms::STATUS_SENT); if (!$this->get('dateSent')) { - $this->set('dateSent', DateTime::createNow()->getString()); + $this->set('dateSent', DateTime::createNow()->toString()); } return $this; diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Items/BusyRange.php b/application/Espo/Modules/Crm/Tools/Calendar/Items/BusyRange.php index 351c8fcee5..0d679dce70 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Items/BusyRange.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Items/BusyRange.php @@ -58,8 +58,8 @@ class BusyRange implements Item public function getRaw(): stdClass { return (object) [ - 'dateStart' => $this->start->getString(), - 'dateEnd' => $this->end->getString(), + 'dateStart' => $this->start->toString(), + 'dateEnd' => $this->end->toString(), 'isBusyRange' => true, ]; } diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Items/Event.php b/application/Espo/Modules/Crm/Tools/Calendar/Items/Event.php index 1a459112eb..e0d77dc5c5 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Items/Event.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Items/Event.php @@ -62,8 +62,8 @@ class Event implements Item { $obj = (object) [ 'scope' => $this->entityType, - 'dateStart' => $this->start?->getString(), - 'dateEnd' => $this->end?->getString(), + 'dateStart' => $this->start?->toString(), + 'dateEnd' => $this->end?->toString(), ]; if ($this->userIdList !== []) { diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Items/NonWorkingRange.php b/application/Espo/Modules/Crm/Tools/Calendar/Items/NonWorkingRange.php index ccccdec896..f2a1837ab4 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Items/NonWorkingRange.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Items/NonWorkingRange.php @@ -57,8 +57,8 @@ class NonWorkingRange implements Item public function getRaw(): stdClass { return (object) [ - 'dateStart' => $this->start->getString(), - 'dateEnd' => $this->end->getString(), + 'dateStart' => $this->start->toString(), + 'dateEnd' => $this->end->toString(), 'isNonWorkingRange' => true, ]; } diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Items/WorkingRange.php b/application/Espo/Modules/Crm/Tools/Calendar/Items/WorkingRange.php index 9663f00034..8c72ac7a98 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Items/WorkingRange.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Items/WorkingRange.php @@ -58,8 +58,8 @@ class WorkingRange implements Item public function getRaw(): stdClass { return (object) [ - 'dateStart' => $this->start->getString(), - 'dateEnd' => $this->end->getString(), + 'dateStart' => $this->start->toString(), + 'dateEnd' => $this->end->toString(), 'isWorkingRange' => true, ]; } diff --git a/application/Espo/Modules/Crm/Tools/Calendar/Service.php b/application/Espo/Modules/Crm/Tools/Calendar/Service.php index 5370883a4e..5d72dc5c72 100644 --- a/application/Espo/Modules/Crm/Tools/Calendar/Service.php +++ b/application/Espo/Modules/Crm/Tools/Calendar/Service.php @@ -85,8 +85,8 @@ class Service */ public function fetch(string $userId, FetchParams $fetchParams): array { - $from = $fetchParams->getFrom()->getString(); - $to = $fetchParams->getTo()->getString(); + $from = $fetchParams->getFrom()->toString(); + $to = $fetchParams->getTo()->toString(); $scopeList = $fetchParams->getScopeList(); $skipAcl = $fetchParams->skipAcl(); @@ -784,26 +784,26 @@ class Service try { foreach ($rangeList as $range) { if ( - $start->getTimestamp() < $range->start->getTimestamp() && - $end->getTimestamp() > $range->end->getTimestamp() + $start->toTimestamp() < $range->start->getTimestamp() && + $end->toTimestamp() > $range->end->getTimestamp() ) { - $range->dateStart = $start->getString(); + $range->dateStart = $start->toString(); $range->start = $start; - $range->dateEnd = $end->getString(); + $range->dateEnd = $end->toString(); $range->end = $end; continue 2; } if ( - $start->getTimestamp() < $range->start->getTimestamp() && - $end->getTimestamp() > $range->start->getTimestamp() + $start->toTimestamp() < $range->start->getTimestamp() && + $end->toTimestamp() > $range->start->getTimestamp() ) { - $range->dateStart = $start->getString(); + $range->dateStart = $start->toString(); $range->start = $start; - if ($end->getTimestamp() > $range->end->getTimestamp()) { - $range->dateEnd = $end->getString(); + if ($end->toTimestamp() > $range->end->getTimestamp()) { + $range->dateEnd = $end->toString(); $range->end = $end; } @@ -811,14 +811,14 @@ class Service } if ( - $start->getTimestamp() < $range->end->getTimestamp() && - $end->getTimestamp() > $range->end->getTimestamp() + $start->toTimestamp() < $range->end->getTimestamp() && + $end->toTimestamp() > $range->end->getTimestamp() ) { - $range->dateEnd = $end->getString(); + $range->dateEnd = $end->toString(); $range->end = $end; - if ($start->getTimestamp() < $range->start->getTimestamp()) { - $range->dateStart = $start->getString(); + if ($start->toTimestamp() < $range->start->getTimestamp()) { + $range->dateStart = $start->toString(); $range->start = $start; } @@ -827,8 +827,8 @@ class Service } $busyItem = (object) [ - 'dateStart' => $start->getString(), - 'dateEnd' => $end->getString(), + 'dateStart' => $start->toString(), + 'dateEnd' => $end->toString(), 'start' => $start, 'end' => $end, ]; @@ -926,7 +926,7 @@ class Service $toReturn = true; try { - $diff = $to->getDateTime()->diff($from->getDateTime(), true); + $diff = $to->toDateTime()->diff($from->toDateTime(), true); if ($diff->days > $this->config->get('busyRangesMaxRange', self::BUSY_RANGES_MAX_RANGE_DAYS)) { $toReturn = false; diff --git a/application/Espo/Modules/Crm/Tools/Campaign/LogService.php b/application/Espo/Modules/Crm/Tools/Campaign/LogService.php index 9325de2186..7140dfa74e 100644 --- a/application/Espo/Modules/Crm/Tools/Campaign/LogService.php +++ b/application/Espo/Modules/Crm/Tools/Campaign/LogService.php @@ -61,7 +61,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $target->getId(), 'parentType' => $target->getEntityType(), 'action' => CampaignLogRecord::ACTION_LEAD_CREATED, @@ -81,7 +81,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $queueItem->getTargetId(), 'parentType' => $queueItem->getTargetType(), 'action' => CampaignLogRecord::ACTION_SENT, @@ -125,7 +125,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $queueItem->getTargetId(), 'parentType' => $queueItem->getTargetType(), 'action' => CampaignLogRecord::ACTION_BOUNCED, @@ -184,7 +184,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $target->getId(), 'parentType' => $target->getEntityType(), 'action' => CampaignLogRecord::ACTION_OPTED_IN, @@ -235,7 +235,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $target->getId(), 'parentType' => $target->getEntityType(), 'action' => CampaignLogRecord::ACTION_OPTED_OUT, @@ -281,7 +281,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $queueItem->getTargetId(), 'parentType' => $queueItem->getTargetType(), 'action' => CampaignLogRecord::ACTION_OPENED, @@ -325,7 +325,7 @@ class LogService $logRecord->set([ 'campaignId' => $campaignId, - 'actionDate' => $actionDate->getString(), + 'actionDate' => $actionDate->toString(), 'parentId' => $queueItem->getTargetId(), 'parentType' => $queueItem->getTargetType(), 'action' => CampaignLogRecord::ACTION_CLICKED, diff --git a/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByLeadSource.php b/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByLeadSource.php index 44be7b332d..f3637d1241 100644 --- a/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByLeadSource.php +++ b/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByLeadSource.php @@ -100,20 +100,20 @@ class ByLeadSource if ($from && $to) { $whereClause[] = [ - 'closeDate>=' => $from->getString(), - 'closeDate<' => $to->getString(), + 'closeDate>=' => $from->toString(), + 'closeDate<' => $to->toString(), ]; } if ($from && !$to) { $whereClause[] = [ - 'closeDate>=' => $from->getString(), + 'closeDate>=' => $from->toString(), ]; } if (!$from && $to) { $whereClause[] = [ - 'closeDate<' => $to->getString(), + 'closeDate<' => $to->toString(), ]; } diff --git a/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByStage.php b/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByStage.php index ffa6939c0e..20719e5f3b 100644 --- a/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByStage.php +++ b/application/Espo/Modules/Crm/Tools/Opportunity/Report/ByStage.php @@ -99,20 +99,20 @@ class ByStage if ($from && $to) { $whereClause[] = [ - 'closeDate>=' => $from->getString(), - 'closeDate<' => $to->getString(), + 'closeDate>=' => $from->toString(), + 'closeDate<' => $to->toString(), ]; } if ($from && !$to) { $whereClause[] = [ - 'closeDate>=' => $from->getString(), + 'closeDate>=' => $from->toString(), ]; } if (!$from && $to) { $whereClause[] = [ - 'closeDate<' => $to->getString(), + 'closeDate<' => $to->toString(), ]; } $queryBuilder diff --git a/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesByMonth.php b/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesByMonth.php index 7870c9a33a..41a17a9308 100644 --- a/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesByMonth.php +++ b/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesByMonth.php @@ -97,8 +97,8 @@ class SalesByMonth ]; $whereClause[] = [ - 'closeDate>=' => $from->getString(), - 'closeDate<' => $to->getString(), + 'closeDate>=' => $from->toString(), + 'closeDate<' => $to->toString(), ]; $queryBuilder @@ -138,8 +138,8 @@ class SalesByMonth $dtTo = $dtTo->addDays(1 - $dtTo->getDay()); } - while ($dt->getTimestamp() < $dtTo->getTimestamp()) { - $month = $dt->getDateTime()->format('Y-m'); + while ($dt->toTimestamp() < $dtTo->toTimestamp()) { + $month = $dt->toDateTime()->format('Y-m'); if (!array_key_exists($month, $result)) { $result[$month] = 0; diff --git a/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesPipeline.php b/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesPipeline.php index 6c923ae92d..fad0f986d6 100644 --- a/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesPipeline.php +++ b/application/Espo/Modules/Crm/Tools/Opportunity/Report/SalesPipeline.php @@ -107,20 +107,20 @@ class SalesPipeline if ($from && $to) { $whereClause[] = [ - 'closeDate>=' => $from->getString(), - 'closeDate<' => $to->getString(), + 'closeDate>=' => $from->toString(), + 'closeDate<' => $to->toString(), ]; } if ($from && !$to) { $whereClause[] = [ - 'closeDate>=' => $from->getString(), + 'closeDate>=' => $from->toString(), ]; } if (!$from && $to) { $whereClause[] = [ - 'closeDate<' => $to->getString(), + 'closeDate<' => $to->toString(), ]; } diff --git a/application/Espo/Tools/Attachment/Jobs/MoveToStorage.php b/application/Espo/Tools/Attachment/Jobs/MoveToStorage.php index 9b0e9c8908..b797e864e2 100644 --- a/application/Espo/Tools/Attachment/Jobs/MoveToStorage.php +++ b/application/Espo/Tools/Attachment/Jobs/MoveToStorage.php @@ -111,7 +111,7 @@ class MoveToStorage implements Job ->setTime( DateTime::createNow() ->modify('+' . self::REMOVE_FILE_PERIOD) - ->getDateTime() + ->toDateTime() ) ->schedule(); } diff --git a/application/Espo/Tools/Export/Format/Xlsx/OpenSpoutProcessor.php b/application/Espo/Tools/Export/Format/Xlsx/OpenSpoutProcessor.php index 4574a770d1..a5d6eb4f84 100644 --- a/application/Espo/Tools/Export/Format/Xlsx/OpenSpoutProcessor.php +++ b/application/Espo/Tools/Export/Format/Xlsx/OpenSpoutProcessor.php @@ -195,7 +195,7 @@ class OpenSpoutProcessor implements ProcessorInterface $style = new Style(); $style->setFormat($dateFormat); - return Cell\DateTimeCell::fromValue($value->getDateTime(), $style); + return Cell\DateTimeCell::fromValue($value->toDateTime(), $style); } if ($value instanceof DateTime) { @@ -204,7 +204,7 @@ class OpenSpoutProcessor implements ProcessorInterface $style = new Style(); $style->setFormat($dateTimeFormat); - return Cell\DateTimeCell::fromValue($value->getDateTime(), $style); + return Cell\DateTimeCell::fromValue($value->toDateTime(), $style); } if ($value instanceof Currency) { diff --git a/application/Espo/Tools/Export/Format/Xlsx/PhpSpreadsheetProcessor.php b/application/Espo/Tools/Export/Format/Xlsx/PhpSpreadsheetProcessor.php index 5d960b5694..f00407f785 100644 --- a/application/Espo/Tools/Export/Format/Xlsx/PhpSpreadsheetProcessor.php +++ b/application/Espo/Tools/Export/Format/Xlsx/PhpSpreadsheetProcessor.php @@ -422,7 +422,7 @@ class PhpSpreadsheetProcessor implements ProcessorInterface $sheet->setCellValue( $coordinate, SharedDate::PHPToExcel( - strtotime($value->getString()) + strtotime($value->toString()) ) ); } @@ -430,7 +430,7 @@ class PhpSpreadsheetProcessor implements ProcessorInterface $sheet->setCellValue( $coordinate, SharedDate::PHPToExcel( - strtotime($value->getDateTime()->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT)) + strtotime($value->toDateTime()->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT)) ) ); } diff --git a/application/Espo/Tools/LeadCapture/CaptureService.php b/application/Espo/Tools/LeadCapture/CaptureService.php index 358d24d147..2c3166817e 100644 --- a/application/Espo/Tools/LeadCapture/CaptureService.php +++ b/application/Espo/Tools/LeadCapture/CaptureService.php @@ -421,7 +421,7 @@ class CaptureService $terminateAt = $uniqueId->getTerminateAt(); - if ($terminateAt && time() > strtotime($terminateAt->getString())) { + if ($terminateAt && time() > strtotime($terminateAt->toString())) { return new ConfirmResult( ConfirmResult::STATUS_EXPIRED, $this->defaultLanguage diff --git a/application/Espo/Tools/LeadCapture/ConfirmationSender.php b/application/Espo/Tools/LeadCapture/ConfirmationSender.php index 7da4d9ea0d..6342e36899 100644 --- a/application/Espo/Tools/LeadCapture/ConfirmationSender.php +++ b/application/Espo/Tools/LeadCapture/ConfirmationSender.php @@ -112,7 +112,7 @@ class ConfirmationSender $terminateAt = $uniqueId->getTerminateAt(); - if ($terminateAt && time() > strtotime($terminateAt->getString())) { + if ($terminateAt && time() > strtotime($terminateAt->toString())) { throw new Error("LeadCapture: Opt-in confirmation expired."); } @@ -192,7 +192,7 @@ class ConfirmationSender $body = str_replace('{optInUrl}', $url, $body); $body = str_replace('{optInLink}', $linkHtml, $body); - $createdAt = $uniqueId->getCreatedAt()->getString(); + $createdAt = $uniqueId->getCreatedAt()->toString(); if ($createdAt) { $dateString = $this->dateTime->convertSystemDateTime($createdAt, null, $this->config->get('dateFormat')); diff --git a/application/Espo/Tools/Stream/Service.php b/application/Espo/Tools/Stream/Service.php index d7766c3b27..dfafa58d9b 100644 --- a/application/Espo/Tools/Stream/Service.php +++ b/application/Espo/Tools/Stream/Service.php @@ -1416,11 +1416,11 @@ class Service } if (!$entity->isNew()) { - if ($createdAt->getTimestamp() < $notificationThreshold->getTimestamp()) { + if ($createdAt->toTimestamp() < $notificationThreshold->getTimestamp()) { $forceProcessNoteNotifications = false; } - if ($createdAt->getTimestamp() < $aclThreshold->getTimestamp()) { + if ($createdAt->toTimestamp() < $aclThreshold->getTimestamp()) { return; } } diff --git a/application/Espo/Tools/UserSecurity/Password/RecoveryService.php b/application/Espo/Tools/UserSecurity/Password/RecoveryService.php index 123a21811c..d88a6e7d2a 100644 --- a/application/Espo/Tools/UserSecurity/Password/RecoveryService.php +++ b/application/Espo/Tools/UserSecurity/Password/RecoveryService.php @@ -353,7 +353,7 @@ class RecoveryService ->setTime( DateTime::createNow() ->modify('+' . $lifetime) - ->getDateTime() + ->toDateTime() ) ->setQueue(QueueName::Q1) ->schedule(); @@ -555,7 +555,7 @@ class RecoveryService return; } - $data->set('lastPasswordRecoveryDate', DateTime::createNow()->getString()); + $data->set('lastPasswordRecoveryDate', DateTime::createNow()->toString()); $this->entityManager->saveEntity($data); } diff --git a/application/Espo/Tools/WorkingTime/Extractor.php b/application/Espo/Tools/WorkingTime/Extractor.php index 2e04ffbaee..966040c14a 100644 --- a/application/Espo/Tools/WorkingTime/Extractor.php +++ b/application/Espo/Tools/WorkingTime/Extractor.php @@ -45,8 +45,8 @@ class Extractor { $pointer = $from->withTimezone($calendar->getTimezone()); - $fromDate = Date::fromDateTime($from->modify('-1 day')->getDateTime()); - $toDate = Date::fromDateTime($from->modify('+1 day')->getDateTime()); + $fromDate = Date::fromDateTime($from->modify('-1 day')->toDateTime()); + $toDate = Date::fromDateTime($from->modify('+1 day')->toDateTime()); $workingDates = $calendar->getWorkingDates($fromDate, $toDate); $nonWorkingDates = $calendar->getNonWorkingDates($fromDate, $toDate); @@ -56,7 +56,7 @@ class Extractor $end = $to->withTimezone($calendar->getTimezone())->withTime(23, 59, 59); - while ($pointer->getTimestamp() < $end->getTimestamp()) { + while ($pointer->toTimestamp() < $end->toTimestamp()) { $list = array_merge( $list, $this->extractIteration( @@ -143,8 +143,8 @@ class Extractor ->withTimezone($calendar->getTimezone()) ->withTime(0, 0, 0); - $fromDate = Date::fromDateTime($from->modify('-1 day')->getDateTime()); - $toDate = Date::fromDateTime($from->modify('+1 day')->getDateTime()); + $fromDate = Date::fromDateTime($from->modify('-1 day')->toDateTime()); + $toDate = Date::fromDateTime($from->modify('+1 day')->toDateTime()); $workingDates = $calendar->getWorkingDates($fromDate, $toDate); $nonWorkingDates = $calendar->getNonWorkingDates($fromDate, $toDate); @@ -154,7 +154,7 @@ class Extractor $end = $to->withTimezone($calendar->getTimezone())->withTime(23, 59, 59); - while ($pointer->getTimestamp() < $end->getTimestamp()) { + while ($pointer->toTimestamp() < $end->toTimestamp()) { $isWorkingDay = $this->isWorkingDay( $pointer, $workingDates, @@ -370,7 +370,7 @@ class Extractor */ private function extractFromDay(DateTime $dateTime, HavingRanges $day): array { - $pointer = $dateTime->getDateTime(); + $pointer = $dateTime->toDateTime(); $list = []; diff --git a/application/Espo/Tools/WorkingTime/GlobalCalendar.php b/application/Espo/Tools/WorkingTime/GlobalCalendar.php index a7e7b95d96..8ddac57549 100644 --- a/application/Espo/Tools/WorkingTime/GlobalCalendar.php +++ b/application/Espo/Tools/WorkingTime/GlobalCalendar.php @@ -139,7 +139,7 @@ class GlobalCalendar implements Calendar */ private function getDates(Date $from, Date $to): array { - $cacheKey = $from->getString() . '-' . $to->getString(); + $cacheKey = $from->toString() . '-' . $to->toString(); if ($this->cacheKey === $cacheKey) { assert($this->cache !== null); @@ -207,11 +207,11 @@ class GlobalCalendar implements Calendar OrGroup::create( Condition::greaterOrEqual( Expression::column('dateEnd'), - $from->getString() + $from->toString() ), Condition::lessOrEqual( Expression::column('dateStart'), - $to->getString() + $to->toString() ), ) ) diff --git a/application/Espo/Tools/WorkingTime/TeamCalendar.php b/application/Espo/Tools/WorkingTime/TeamCalendar.php index 5f12f8de64..66cb8aec8a 100644 --- a/application/Espo/Tools/WorkingTime/TeamCalendar.php +++ b/application/Espo/Tools/WorkingTime/TeamCalendar.php @@ -160,7 +160,7 @@ class TeamCalendar implements Calendar */ private function getDates(Date $from, Date $to): array { - $cacheKey = $from->getString() . '-' . $to->getString(); + $cacheKey = $from->toString() . '-' . $to->toString(); if ($this->cacheKey === $cacheKey) { assert($this->cache !== null); @@ -228,11 +228,11 @@ class TeamCalendar implements Calendar OrGroup::create( Condition::greaterOrEqual( Expression::column('dateEnd'), - $from->getString() + $from->toString() ), Condition::lessOrEqual( Expression::column('dateStart'), - $to->getString() + $to->toString() ), ) ) diff --git a/application/Espo/Tools/WorkingTime/UserCalendar.php b/application/Espo/Tools/WorkingTime/UserCalendar.php index db5f3d7bc9..45c1ebca55 100644 --- a/application/Espo/Tools/WorkingTime/UserCalendar.php +++ b/application/Espo/Tools/WorkingTime/UserCalendar.php @@ -183,7 +183,7 @@ class UserCalendar implements Calendar */ private function getDates(Date $from, Date $to): array { - $cacheKey = $from->getString() . '-' . $to->getString(); + $cacheKey = $from->toString() . '-' . $to->toString(); if ($this->cacheKey === $cacheKey) { assert($this->cache !== null); @@ -219,7 +219,7 @@ class UserCalendar implements Calendar $dates = array_filter( $this->rangeToDates($range), function (WorkingDate $date) use ($metMap) { - return !array_key_exists($date->getDate()->getString(), $metMap); + return !array_key_exists($date->getDate()->toString(), $metMap); } ); @@ -271,11 +271,11 @@ class UserCalendar implements Calendar OrGroup::create( Condition::greaterOrEqual( Expression::column('dateEnd'), - $from->getString() + $from->toString() ), Condition::lessOrEqual( Expression::column('dateStart'), - $to->getString() + $to->toString() ), ) ) @@ -312,11 +312,11 @@ class UserCalendar implements Calendar OrGroup::create( Condition::greaterOrEqual( Expression::column('dateEnd'), - $from->getString() + $from->toString() ), Condition::lessOrEqual( Expression::column('dateStart'), - $to->getString() + $to->toString() ), ) ) diff --git a/tests/integration/Espo/Core/Formula/FormulaTest.php b/tests/integration/Espo/Core/Formula/FormulaTest.php index b69a10628f..cebedd884b 100644 --- a/tests/integration/Espo/Core/Formula/FormulaTest.php +++ b/tests/integration/Espo/Core/Formula/FormulaTest.php @@ -841,32 +841,32 @@ class FormulaTest extends BaseTestCase $script = sprintf( "ext\\calendar\\userIsBusy('%s', '%s', '%s')", $user->getId(), - $dateStart->getString(), - $dateEnd->getString() + $dateStart->toString(), + $dateEnd->toString() ); $this->assertTrue($fm->run($script)); $script = sprintf( "ext\\calendar\\userIsBusy('%s', '%s', '%s')", $user->getId(), - $dateStart->addHours(-1)->getString(), - $dateEnd->addHours(1)->getString() + $dateStart->addHours(-1)->toString(), + $dateEnd->addHours(1)->toString() ); $this->assertTrue($fm->run($script)); $script = sprintf( "ext\\calendar\\userIsBusy('%s', '%s', '%s')", $user->getId(), - $dateStart->addDays(-1)->getString(), - $dateEnd->addDays(-1)->getString() + $dateStart->addDays(-1)->toString(), + $dateEnd->addDays(-1)->toString() ); $this->assertFalse($fm->run($script)); $script = sprintf( "ext\\calendar\\userIsBusy('%s', '%s', '%s', '%s', '%s')", $user->getId(), - $dateStart->getString(), - $dateEnd->getString(), + $dateStart->toString(), + $dateEnd->toString(), $meeting->getEntityType(), $meeting->getId() ); diff --git a/tests/integration/Espo/Record/LinkTest.php b/tests/integration/Espo/Record/LinkTest.php index bb8e0e5dfd..fe4f13e2c8 100644 --- a/tests/integration/Espo/Record/LinkTest.php +++ b/tests/integration/Espo/Record/LinkTest.php @@ -129,7 +129,7 @@ class LinkTest extends BaseTestCase 'amount' => 1.0, 'amountCurrency' => 'USD', 'probability' => 10, - 'closeDate' => Date::createToday()->getString(), + 'closeDate' => Date::createToday()->toString(), ], CreateParams::create()); $isThrown = false; @@ -143,7 +143,7 @@ class LinkTest extends BaseTestCase 'amount' => 1.0, 'amountCurrency' => 'USD', 'probability' => 10, - 'closeDate' => Date::createToday()->getString(), + 'closeDate' => Date::createToday()->toString(), ], CreateParams::create()); } catch (Forbidden) { @@ -229,7 +229,7 @@ class LinkTest extends BaseTestCase 'amount' => 1.0, 'amountCurrency' => 'USD', 'probability' => 10, - 'closeDate' => Date::createToday()->getString(), + 'closeDate' => Date::createToday()->toString(), ], CreateParams::create()); } } diff --git a/tests/integration/Espo/User/AclTest.php b/tests/integration/Espo/User/AclTest.php index 45e3460107..744092631f 100644 --- a/tests/integration/Espo/User/AclTest.php +++ b/tests/integration/Espo/User/AclTest.php @@ -623,7 +623,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase 'probability' => 10, 'amount' => 1, 'contactsIds' => [], - 'closeDate' => Date::createToday()->getString(), + 'closeDate' => Date::createToday()->toString(), 'assignedUserId' => $userId, ], CreateParams::create()); @@ -633,7 +633,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase 'amount' => 1, 'probability' => 10, 'contactsIds' => [$contact1->getId()], - 'closeDate' => Date::createToday()->getString(), + 'closeDate' => Date::createToday()->toString(), 'assignedUserId' => $userId, ], CreateParams::create()); @@ -669,7 +669,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase 'amount' => 1, 'probability' => 10, 'contactsIds' => [$contact2->getId()], - 'closeDate' => Date::createToday()->getString(), + 'closeDate' => Date::createToday()->toString(), 'assignedUserId' => $userId, ], CreateParams::create()); } diff --git a/tests/unit/Espo/Core/Field/Date/DateTest.php b/tests/unit/Espo/Core/Field/Date/DateTest.php index 6e4f816976..8fa762a1e6 100644 --- a/tests/unit/Espo/Core/Field/Date/DateTest.php +++ b/tests/unit/Espo/Core/Field/Date/DateTest.php @@ -44,7 +44,7 @@ class DateTest extends \PHPUnit\Framework\TestCase { $value = Date::fromString('2021-05-01'); - $this->assertEquals('2021-05-01', $value->getString()); + $this->assertEquals('2021-05-01', $value->toString()); } public function testFromDateTime() @@ -53,7 +53,7 @@ class DateTest extends \PHPUnit\Framework\TestCase $value = Date::fromDateTime($dt); - $this->assertEquals('2021-05-01', $value->getString()); + $this->assertEquals('2021-05-01', $value->toString()); } public function testBad1() @@ -81,7 +81,7 @@ class DateTest extends \PHPUnit\Framework\TestCase { $value = Date::fromString('2021-05-01'); - $this->assertEquals('2021-05-01', $value->getDateTime()->format('Y-m-d')); + $this->assertEquals('2021-05-01', $value->toDateTime()->format('Y-m-d')); } public function testGetMethods() @@ -95,7 +95,7 @@ class DateTest extends \PHPUnit\Framework\TestCase $this->assertEquals(2021, $value->getYear()); $this->assertEquals(6, $value->getDayOfWeek()); - $this->assertEquals($dt->getTimestamp(), $value->getTimestamp()); + $this->assertEquals($dt->getTimestamp(), $value->toTimestamp()); } public function testAdd() @@ -104,7 +104,7 @@ class DateTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->add(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-05-02', $modifiedValue->getString()); + $this->assertEquals('2021-05-02', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -115,7 +115,7 @@ class DateTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->subtract(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-04-30', $modifiedValue->getString()); + $this->assertEquals('2021-04-30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -126,7 +126,7 @@ class DateTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->modify('+1 month'); - $this->assertEquals('2021-06-01', $modifiedValue->getString()); + $this->assertEquals('2021-06-01', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } diff --git a/tests/unit/Espo/Core/Field/DateTime/DateTimeTest.php b/tests/unit/Espo/Core/Field/DateTime/DateTimeTest.php index 7bf6e91579..e9dc706a05 100644 --- a/tests/unit/Espo/Core/Field/DateTime/DateTimeTest.php +++ b/tests/unit/Espo/Core/Field/DateTime/DateTimeTest.php @@ -42,14 +42,14 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase { $value = DateTime::fromString('2021-05-01 10:20:30'); - $this->assertEquals('2021-05-01 10:20:30', $value->getString()); + $this->assertEquals('2021-05-01 10:20:30', $value->toString()); } public function testFromString2() { $value = DateTime::fromString('2021-05-01 10:20'); - $this->assertEquals('2021-05-01 10:20:00', $value->getString()); + $this->assertEquals('2021-05-01 10:20:00', $value->toString()); } public function testFromDateTime1() @@ -58,7 +58,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $value = DateTime::fromDateTime($dt); - $this->assertEquals('2021-05-01 10:20:30', $value->getString()); + $this->assertEquals('2021-05-01 10:20:30', $value->toString()); } public function testFromDateTime2() @@ -67,7 +67,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $value = DateTime::fromDateTime($dt); - $this->assertEquals('2021-05-01 07:20:30', $value->getString()); + $this->assertEquals('2021-05-01 07:20:30', $value->toString()); } public function testBad1() @@ -95,7 +95,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase { $value = DateTime::fromString('2021-05-01 10:20:30'); - $this->assertEquals('2021-05-01', $value->getDateTime()->format('Y-m-d')); + $this->assertEquals('2021-05-01', $value->toDateTime()->format('Y-m-d')); } public function testGetMethods() @@ -112,7 +112,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $this->assertEquals(20, $value->getMinute()); $this->assertEquals(30, $value->getSecond()); - $this->assertEquals($dt->getTimestamp(), $value->getTimestamp()); + $this->assertEquals($dt->getTimestamp(), $value->toTimestamp()); } public function testAdd() @@ -121,7 +121,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->add(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-05-02 10:20:30', $modifiedValue->getString()); + $this->assertEquals('2021-05-02 10:20:30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -132,7 +132,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->subtract(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-04-30 10:20:30', $modifiedValue->getString()); + $this->assertEquals('2021-04-30 10:20:30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -143,7 +143,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->modify('+1 month'); - $this->assertEquals('2021-06-01 10:20:30', $modifiedValue->getString()); + $this->assertEquals('2021-06-01 10:20:30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -154,7 +154,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase ::fromString('2021-05-01 10:20:30') ->withTimezone(new DateTimeZone('Europe/Kiev')); - $this->assertEquals('2021-05-01 10:20:30', $value->getString()); + $this->assertEquals('2021-05-01 10:20:30', $value->toString()); $this->assertEquals(13, $value->getHour()); } @@ -190,22 +190,22 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $this->assertEquals( '2021-05-01 00:00:00', - $value->withTime(0, 0, 0)->getString() + $value->withTime(0, 0, 0)->toString() ); $this->assertEquals( '2021-05-01 00:10:30', - $value->withTime(0, null, null)->getString() + $value->withTime(0, null, null)->toString() ); $this->assertEquals( '2021-05-01 10:00:00', - $value->withTime(null, 0)->getString() + $value->withTime(null, 0)->toString() ); $this->assertEquals( '2021-05-01 10:00:10', - $value->withTime(null, 0, 10)->getString() + $value->withTime(null, 0, 10)->toString() ); } @@ -377,7 +377,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase $value = DateTime::fromTimestamp($timestamp); - $this->assertEquals($timestamp, $value->getTimestamp()); + $this->assertEquals($timestamp, $value->toTimestamp()); } } diff --git a/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalDateTest.php b/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalDateTest.php index 584000a58e..4af9081f29 100644 --- a/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalDateTest.php +++ b/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalDateTest.php @@ -44,7 +44,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase { $value = DateTimeOptional::fromString('2021-05-01'); - $this->assertEquals('2021-05-01', $value->getString()); + $this->assertEquals('2021-05-01', $value->toString()); $this->assertTrue($value->isAllDay()); } @@ -55,7 +55,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase $value = DateTimeOptional::fromDateTimeAllDay($dt); - $this->assertEquals('2021-05-01', $value->getString()); + $this->assertEquals('2021-05-01', $value->toString()); } public function testBad1() @@ -83,14 +83,14 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase { $value = DateTimeOptional::fromString('2021-05-01'); - $this->assertEquals('2021-05-01', $value->getDateTime()->format('Y-m-d')); + $this->assertEquals('2021-05-01', $value->toDateTime()->format('Y-m-d')); } public function testGetTimezone() { $value = DateTimeOptional::fromString('2021-05-01'); - $this->assertEquals(new DateTimeZone('UTC'), $value->getDateTime()->getTimezone()); + $this->assertEquals(new DateTimeZone('UTC'), $value->toDateTime()->getTimezone()); } public function testGetMethods() @@ -104,7 +104,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase $this->assertEquals(2021, $value->getYear()); $this->assertEquals(6, $value->getDayOfWeek()); - $this->assertEquals($dt->getTimestamp(), $value->getTimestamp()); + $this->assertEquals($dt->getTimestamp(), $value->toTimestamp()); } public function testAdd() @@ -113,7 +113,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->add(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-05-02', $modifiedValue->getString()); + $this->assertEquals('2021-05-02', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -124,7 +124,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->subtract(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-04-30', $modifiedValue->getString()); + $this->assertEquals('2021-04-30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -135,7 +135,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->modify('+1 month'); - $this->assertEquals('2021-06-01', $modifiedValue->getString()); + $this->assertEquals('2021-06-01', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -146,7 +146,7 @@ class DateTimeOptionalDateTest extends \PHPUnit\Framework\TestCase ::fromString('2021-05-01') ->withTimezone(new DateTimeZone('Europe/Kiev')); - $this->assertEquals('2021-05-01 00:00:00', $value->getString()); + $this->assertEquals('2021-05-01 00:00:00', $value->toString()); $this->assertEquals(new DateTimeZone('Europe/Kiev'), $value->getTimezone()); diff --git a/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalTest.php b/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalTest.php index a13af9540f..641b9fbba6 100644 --- a/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalTest.php +++ b/tests/unit/Espo/Core/Field/DateTimeOptional/DateTimeOptionalTest.php @@ -44,7 +44,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase { $value = DateTimeOptional::fromString('2021-05-01 10:20:30'); - $this->assertEquals('2021-05-01 10:20:30', $value->getString()); + $this->assertEquals('2021-05-01 10:20:30', $value->toString()); $this->assertFalse($value->isAllDay()); } @@ -53,7 +53,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase { $value = DateTimeOptional::fromString('2021-05-01 10:20'); - $this->assertEquals('2021-05-01 10:20:00', $value->getString()); + $this->assertEquals('2021-05-01 10:20:00', $value->toString()); $this->assertFalse($value->isAllDay()); } @@ -64,7 +64,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $value = DateTimeOptional::fromDateTime($dt); - $this->assertEquals('2021-05-01 10:20:30', $value->getString()); + $this->assertEquals('2021-05-01 10:20:30', $value->toString()); } public function testFromDateTime2() @@ -73,7 +73,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $value = DateTimeOptional::fromDateTime($dt); - $this->assertEquals('2021-05-01 07:20:30', $value->getString()); + $this->assertEquals('2021-05-01 07:20:30', $value->toString()); } public function testBad1() @@ -101,7 +101,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase { $value = DateTimeOptional::fromString('2021-05-01 10:20:30'); - $this->assertEquals('2021-05-01', $value->getDateTime()->format('Y-m-d')); + $this->assertEquals('2021-05-01', $value->toDateTime()->format('Y-m-d')); } public function testGetMethods() @@ -127,7 +127,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->add(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-05-02 10:20:30', $modifiedValue->getString()); + $this->assertEquals('2021-05-02 10:20:30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -138,7 +138,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->subtract(DateInterval::createFromDateString('1 day')); - $this->assertEquals('2021-04-30 10:20:30', $modifiedValue->getString()); + $this->assertEquals('2021-04-30 10:20:30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -149,7 +149,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $modifiedValue = $value->modify('+1 month'); - $this->assertEquals('2021-06-01 10:20:30', $modifiedValue->getString()); + $this->assertEquals('2021-06-01 10:20:30', $modifiedValue->toString()); $this->assertNotSame($modifiedValue, $value); } @@ -160,7 +160,7 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase ::fromString('2021-05-01 10:20:30') ->withTimezone(new DateTimeZone('Europe/Kiev')); - $this->assertEquals('2021-05-01 10:20:30', $value->getString()); + $this->assertEquals('2021-05-01 10:20:30', $value->toString()); $this->assertEquals(13, $value->getHour()); } @@ -197,22 +197,22 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $this->assertEquals( '2021-05-01 00:00:00', - $value->withTime(0, 0, 0)->getString() + $value->withTime(0, 0, 0)->toString() ); $this->assertEquals( '2021-05-01 00:10:30', - $value->withTime(0, null, null)->getString() + $value->withTime(0, null, null)->toString() ); $this->assertEquals( '2021-05-01 10:00:00', - $value->withTime(null, 0)->getString() + $value->withTime(null, 0)->toString() ); $this->assertEquals( '2021-05-01 10:00:10', - $value->withTime(null, 0, 10)->getString() + $value->withTime(null, 0, 10)->toString() ); } @@ -222,22 +222,22 @@ class DateTimeOptionalTest extends \PHPUnit\Framework\TestCase $this->assertEquals( '2021-05-01 00:00:00', - $value->withTime(0, 0, 0)->getString() + $value->withTime(0, 0, 0)->toString() ); $this->assertEquals( '2021-05-01 00:00:00', - $value->withTime(0, null, null)->getString() + $value->withTime(0, null, null)->toString() ); $this->assertEquals( '2021-05-01 00:00:00', - $value->withTime(null, 0)->getString() + $value->withTime(null, 0)->toString() ); $this->assertEquals( '2021-05-01 00:00:10', - $value->withTime(null, 0, 10)->getString() + $value->withTime(null, 0, 10)->toString() ); } diff --git a/tests/unit/Espo/Core/Mail/Account/FetchDataTest.php b/tests/unit/Espo/Core/Mail/Account/FetchDataTest.php index 1ea1a54b04..02bdcdf0e3 100644 --- a/tests/unit/Espo/Core/Mail/Account/FetchDataTest.php +++ b/tests/unit/Espo/Core/Mail/Account/FetchDataTest.php @@ -49,7 +49,7 @@ class FetchDataTest extends \PHPUnit\Framework\TestCase $data = FetchData::fromRaw($raw); $this->assertEquals('10', $data->getLastUniqueId('test')); - $this->assertEquals('2022-01-01 00:00:00', $data->getLastDate('test')->getString()); + $this->assertEquals('2022-01-01 00:00:00', $data->getLastDate('test')->toString()); $this->assertEquals(null, $data->getLastUniqueId('not-existing')); $this->assertEquals(null, $data->getLastDate('not-existing')); $this->assertEquals(false, $data->getForceByDate('test'));