datetime refactoring

This commit is contained in:
Yuri Kuznetsov
2021-04-20 19:27:12 +03:00
parent 302833eb22
commit 5801c329b2
3 changed files with 16 additions and 10 deletions
+12 -6
View File
@@ -36,11 +36,15 @@ use Exception;
use DateTime as DateTimeStd;
/**
* Util for a date-time formatting and convetion.
* Util for a date-time formatting and conversion.
* Available as 'dateTime' service.
*/
class DateTime
{
public const SYSTEM_DATE_TIME_FORMAT = 'Y-m-d H:i:s';
public const SYSTEM_DATE_FORMAT = 'Y-m-d';
protected $dateFormat;
protected $timeFormat;
@@ -49,13 +53,15 @@ class DateTime
protected $langauge;
public static $systemDateTimeFormat = 'Y-m-d H:i:s';
/** @deprecated */
public static $systemDateTimeFormat = self::SYSTEM_DATE_TIME_FORMAT;
public static $systemDateFormat = 'Y-m-d';
/** @deprecated */
public static $systemDateFormat = self::SYSTEM_DATE_FORMAT;
protected $internalDateTimeFormat = 'Y-m-d H:i:s';
protected $internalDateTimeFormat = self::SYSTEM_DATE_TIME_FORMAT;
protected $internalDateFormat = 'Y-m-d';
protected $internalDateFormat = self::SYSTEM_DATE_FORMAT;
protected $dateFormats = [
'MM/DD/YYYY' => 'm/d/Y',
@@ -258,6 +264,6 @@ class DateTime
public static function getSystemNowString(): string
{
return date(self::$systemDateTimeFormat);
return date(self::SYSTEM_DATE_TIME_FORMAT);
}
}
+2 -2
View File
@@ -123,7 +123,7 @@ class ScheduledJob
$r2From = new DateTime('-1 hour');
$r2To = new DateTime();
$format = DateTimeUtil::$systemDateTimeFormat;
$format = DateTimeUtil::SYSTEM_DATE_TIME_FORMAT;
$selectParams = [
'select' => ['id'],
@@ -131,7 +131,7 @@ class ScheduledJob
'whereClause' => [
'OR' => [
[
['executedAt>=' => $r2From->format($format)] ,
['executedAt>=' => $r2From->format($format)],
['executedAt<=' => $r2To->format($format)],
],
[
+2 -2
View File
@@ -46,7 +46,7 @@ use Exception;
use DateTime;
/**
* Groups ocurred events into portions and sends them. A portion contains
* Groups occurred events into portions and sends them. A portion contains
* multiple events of the same webhook.
*/
class Queue
@@ -362,7 +362,7 @@ class Queue
$item->set([
'attempts' => $attempts,
'processAt' => $dt->format(DateTimeUtil::$systemDateTimeFormat),
'processAt' => $dt->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT),
]);
if ($attempts >= $maxAttemptsNumber) {