Skip to content

Commit 8b74ce7

Browse files
committed
compatibility with future Nette\Utils\DateTime
1 parent 4210d9e commit 8b74ce7

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/Http/Helpers.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ final class Helpers
2626
*/
2727
public static function formatDate($time): string
2828
{
29-
$time = DateTime::from($time);
30-
$time->setTimezone(new \DateTimeZone('GMT'));
29+
$time = DateTime::from($time)->setTimezone(new \DateTimeZone('GMT'));
3130
return $time->format('D, d M Y H:i:s \G\M\T');
3231
}
3332

src/Http/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Session
2020
use Nette\SmartObject;
2121

2222
/** Default file lifetime */
23-
private const DEFAULT_FILE_LIFETIME = 3 * Nette\Utils\DateTime::HOUR;
23+
private const DEFAULT_FILE_LIFETIME = '3 hours';
2424

2525
/** @var bool has been session ID regenerated? */
2626
private $regenerated = FALSE;

tests/Http/SessionSection.setExpiration().phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test(function () use ($session) { // try to expire whole namespace
3535

3636
test(function () use ($session) { // try to expire only 1 of the keys
3737
$namespace = $session->getSection('expireSingle');
38-
$namespace->setExpiration(1, 'g');
38+
$namespace->setExpiration('1 second', 'g');
3939
$namespace->g = 'guava';
4040
$namespace->p = 'plum';
4141

@@ -51,5 +51,5 @@ test(function () use ($session) { // try to expire only 1 of the keys
5151
// small expiration
5252
Assert::error(function () use ($session) {
5353
$namespace = $session->getSection('tmp');
54-
$namespace->setExpiration(100);
54+
$namespace->setExpiration('100 second');
5555
}, E_USER_NOTICE, 'The expiration time is greater than the session expiration 10 seconds');

tests/Http/SessionSection.setExpirationUnlimited.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ $session->setOptions(['gc_maxlifetime' => '0']); //memcache handler supports unl
1818

1919
//try to set section to shorter expiration
2020
$namespace = $session->getSection('maxlifetime');
21-
$namespace->setExpiration(100);
21+
$namespace->setExpiration('100 seconds');
2222

2323
Assert::same(TRUE, TRUE); // fix Error: This test forgets to execute an assertion.

0 commit comments

Comments
 (0)