Skip to content

Commit

Permalink
[general] Upgraded date time factory dueto testing issues (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 29, 2024
1 parent ea6869e commit 328e14e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"contributte/monolog": "^0.5",
"cweagans/composer-patches": "^1.7",
"doctrine/orm": "2.15.*",
"fastybird/datetime-factory": "^0.6",
"fastybird/datetime-factory": "^0.7.1",
"fastybird/metadata-library": "dev-main",
"fastybird/simple-auth": "^0.14",
"ipub/doctrine-timestampable": "^2.0",
Expand All @@ -47,6 +47,7 @@
"nette/di": "^3.0",
"nette/utils": "^4.0",
"orisai/nette-object-mapper": "^0.1",
"orisai/object-mapper": "^0.2",
"react/event-loop": "^1.3",
"sentry/sdk": "^3.1",
"symfony/monolog-bridge": "^6.1",
Expand Down
13 changes: 3 additions & 10 deletions src/Utilities/DateTimeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use DateTimeInterface;
use FastyBird\DateTimeFactory;
use IPub\DoctrineTimestampable\Providers as DoctrineTimestampableProviders;
use Nette\DI;

/**
* Date provider for doctrine timestampable
Expand All @@ -31,24 +30,18 @@
readonly class DateTimeProvider implements DoctrineTimestampableProviders\DateProvider
{

public function __construct(private DI\Container $container)
public function __construct(private DateTimeFactory\Clock $clock)
{
}

/**
* @throws DI\MissingServiceException
*/
public function getDate(): DateTimeInterface
{
return $this->container->getByType(DateTimeFactory\Factory::class)->getNow();
return $this->clock->getNow();
}

/**
* @throws DI\MissingServiceException
*/
public function getTimestamp(): int
{
return $this->container->getByType(DateTimeFactory\Factory::class)->getNow()->getTimestamp();
return $this->clock->getNow()->getTimestamp();
}

}

0 comments on commit 328e14e

Please sign in to comment.