From d0155b21c50b928fe419e9d7d34b94ecb6408266 Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Thu, 4 Jan 2018 13:53:05 +0300 Subject: [PATCH 1/2] add timezone option --- src/Formatter/Header.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Formatter/Header.php b/src/Formatter/Header.php index 1d968a3..bec2b5e 100644 --- a/src/Formatter/Header.php +++ b/src/Formatter/Header.php @@ -39,6 +39,11 @@ class Header */ private $encoding; + /** + * @var string + */ + private $timezone; + /** * @param Cron $cron */ @@ -139,6 +144,18 @@ public function setContentTransferEncoding($encoding) return $this; } + /** + * @param $timezone + * + * @return $this + */ + public function setTimezone($timezone) + { + $this->timezone = $timezone; + + return $this; + } + /** * @return string */ @@ -163,6 +180,9 @@ public function format() if ($this->encoding) { $headers .= $this->createHeader('CONTENT_TRANSFER_ENCODING', $this->encoding); } + if ($this->timezone) { + $headers .= $this->createHeader('CRON_TZ', $this->timezone); + } return $headers; } From e7aea8a862d47c337a8e5c58913d263bfbe65ca5 Mon Sep 17 00:00:00 2001 From: Farhad Safarov Date: Thu, 4 Jan 2018 14:47:33 +0300 Subject: [PATCH 2/2] add test --- tests/Formatter/CronTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Formatter/CronTest.php b/tests/Formatter/CronTest.php index 16585ae..bcd32dd 100644 --- a/tests/Formatter/CronTest.php +++ b/tests/Formatter/CronTest.php @@ -24,6 +24,7 @@ public function shouldBuildConfiguration() ->setShell('shell') ->setContentType('text') ->setContentTransferEncoding('utf8') + ->setTimezone('Europe/Paris') ->end() ->comment('This is a command!') ->job('/bin/bash command --env=dev') @@ -49,6 +50,7 @@ public function shouldBuildConfiguration() SHELL=shell CONTENT_TYPE=text CONTENT_TRANSFER_ENCODING=utf8 +CRON_TZ=Europe/Paris #This is a command! 1 2 3 4 5 /bin/bash command --env=dev > log 2>> error