Skip to content

Commit

Permalink
Merge pull request #22 from seferov/timezone
Browse files Browse the repository at this point in the history
add timezone option (CRON_TZ)
  • Loading branch information
gavinlove authored Jan 4, 2018
2 parents 15307a5 + e7aea8a commit b571c1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Formatter/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class Header
*/
private $encoding;

/**
* @var string
*/
private $timezone;

/**
* @param Cron $cron
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Formatter/CronTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit b571c1b

Please sign in to comment.