delete kafka

This commit is contained in:
2021-08-26 15:03:19 +08:00
parent 835300e3c6
commit 8bf0941f2b
17 changed files with 102 additions and 2221 deletions
+28 -29
View File
@@ -22,29 +22,24 @@ class Crontab
public int $loopType = Crontab::LOOP_TYPE_MINUTE;
private int $startTime = 0;
public int $loopTime = 2;
private int|string $year = 2021;
private int|string $month = '*';
private int|string $day = '*';
private int|string $month = 8;
private int|string $hour = '*';
private int|string $day = 25;
private int|string $minute = '*/2';
private int|string $hour = 19;
private int|string $second = '1-30';
private int|string $minute = 02;
private int|string $second = 32;
private int|string $week = '*';
public function __construct()
{
$this->startTime = time();
}
@@ -63,33 +58,30 @@ class Crontab
public function next(): string
{
if ($this->loopType == Crontab::LOOP_TYPE_YEAR) $this->year = '*/' . $this->loopTime;
if ($this->loopType == Crontab::LOOP_TYPE_MONTH) $this->month = '*/' . $this->loopTime;
if ($this->loopType == Crontab::LOOP_TYPE_DAY) $this->day = '*/' . $this->loopTime;
if ($this->loopType == Crontab::LOOP_TYPE_HOUR) $this->hour = '*/' . $this->loopTime;
if ($this->loopType == Crontab::LOOP_TYPE_MINUTE) $this->minute = '*/' . $this->loopTime;
if ($this->loopType == Crontab::LOOP_TYPE_SECOND) $this->second = '*/' . $this->loopTime;
return sprintf('%s-%s-%s %s:%s:%s',
$this->format($this->year, 'Y'),
$this->format($this->month, 'm'),
$this->format($this->day, 'd'),
$this->format($this->hour, 'H'),
$this->format($this->minute, 'i'),
$this->format($this->second, 's')
$time = time();
return sprintf('%s-%s-%s %s:%s:%s %s',
date('Y'),
$this->format($time, $this->month, 'm', 'month'),
$this->format($time, $this->day, 'd', 'day'),
$this->format($time, $this->hour, 'H', 'hour'),
$this->format($time, $this->minute, 'i', 'minute'),
$this->format($time, $this->second, 's', 'second'),
$this->format($time, $this->week, 'N'),
);
}
/**
* @param int $startTime
* @param string $text
* @param string $match
* @param string|null $format
* @return string
*/
private function format(string $text, string $match): string
private function format(int &$startTime, string $text, string $match, ?string $format = null): string
{
$time = date($match);
if ($text == '*') {
if ($text == '*' || $text == '*/1') {
return $time;
}
if (str_contains($text, ',')) {
@@ -103,13 +95,13 @@ class Crontab
if (str_contains($text, '-')) {
$explode = explode('-', $text);
if ($time >= $explode[0] && $time <= $explode[1]) {
return intval($time) + 1;
return intval($time);
}
return '^';
}
if (str_contains($text, '/')) {
$explode = explode('/', $text);
if ($time % $this->loopTime !== 0) {
if ($time % $explode[1] !== 0) {
return '^';
}
if ($explode[0] != '*') {
@@ -123,6 +115,13 @@ class Crontab
}
//$date = date('Y-m-d H:i:s');
//var_dump(date('Y-m-d H:i:s', strtotime('+10 month', strtotime($date))));
//var_dump(date('Y-m-d H:i:s', strtotime('+10 day', strtotime($date))));
//var_dump(date('Y-m-d H:i:s', strtotime('+10 hour', strtotime($date))));
//var_dump(date('Y-m-d H:i:s', strtotime('+10 minute', strtotime($date))));
//var_dump(date('Y-m-d H:i:s', strtotime('+10 second', strtotime($date))));
//var_dump(date('Y-m-d H:i:s', strtotime('+10 week', strtotime($date))));
$c = new Crontab();