Skip to content

Commit

Permalink
Configurator: added setTimeZone()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 25, 2016
1 parent 6743cfe commit 322f415
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Bootstrap/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ public function setTempDirectory($path)
}


/**
* Sets the default timezone.
* @return self
*/
public function setTimeZone($timezone)
{
date_default_timezone_set($timezone);

This comment has been minimized.

Copy link
@JanTvrdik

JanTvrdik Jun 27, 2016

Contributor

Why is date_default_timezone_set not enough?

This comment has been minimized.

Copy link
@dg

dg Jun 27, 2016

Author Member
@ini_set('date.timezone', $timezone); // @ - function may be disabled
return $this;
}


/**
* Adds new parameters. The %params% will be expanded.
* @return self
Expand Down
21 changes: 21 additions & 0 deletions tests/Bootstrap/Configurator.timezone.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* Test: Nette\Configurator and setTimeZone()
*/

use Nette\Configurator;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';


date_default_timezone_set('America/Los_Angeles');

$configurator = new Configurator;
$configurator->setTempDirectory(TEMP_DIR);
$configurator->setTimeZone('Europe/Prague');

Assert::same('Europe/Prague', date_default_timezone_get());
Assert::same('Europe/Prague', ini_get('date.timezone'));

0 comments on commit 322f415

Please sign in to comment.