From 79d3dda85b25dc603908a049bdc1a220ddfef2b6 Mon Sep 17 00:00:00 2001 From: Valentin Silvestre Date: Wed, 13 Mar 2024 15:02:12 +0100 Subject: [PATCH] Add possibility of time date format 12/24 --- src/Humanizer/CronExpressionHumanizer.php | 4 ++-- src/Resources/config/services.yaml | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Humanizer/CronExpressionHumanizer.php b/src/Humanizer/CronExpressionHumanizer.php index 4ddd4b0..e4cc8d0 100644 --- a/src/Humanizer/CronExpressionHumanizer.php +++ b/src/Humanizer/CronExpressionHumanizer.php @@ -10,7 +10,7 @@ class CronExpressionHumanizer implements HumanizerInterface { - public function __construct(private LocaleContextInterface $localeContext) + public function __construct(private LocaleContextInterface $localeContext, private bool $timeFormat24Hours = false) { } @@ -23,7 +23,7 @@ public function humanize(string $expression): string $locale = $this->getLocale(); try { - return CronTranslator::translate($expression, $locale); + return CronTranslator::translate($expression, $locale, $this->timeFormat24Hours); } catch (\Throwable) { return $expression; } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index d1589b7..bbe40ac 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -2,6 +2,7 @@ parameters: env(SYNOLIA_SCHEDULER_PLUGIN_PING_INTERVAL): 300 env(SYNOLIA_SCHEDULER_PLUGIN_KEEP_ALIVE): true env(SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR): '%kernel.logs_dir%' + env(SYNOLIA_SCHEDULER_PLUGIN_TIMEFORMAT_24H): false services: _defaults: @@ -11,6 +12,7 @@ services: bind: $logsDir: '%env(string:SYNOLIA_SCHEDULER_PLUGIN_LOGS_DIR)%' $projectDir: '%kernel.project_dir%' + $timeFormat24Hours: '%env(bool:SYNOLIA_SCHEDULER_PLUGIN_TIMEFORMAT_24H)%' Synolia\SyliusSchedulerCommandPlugin\: resource: '../../*' @@ -62,10 +64,6 @@ services: tags: - { name: !php/const Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface::TAG_ID } - Synolia\SyliusSchedulerCommandPlugin\Checker\SoftLimitThresholdIsDueChecker: - tags: - - { name: !php/const Synolia\SyliusSchedulerCommandPlugin\Checker\IsDueCheckerInterface::TAG_ID } - Synolia\SyliusSchedulerCommandPlugin\Voter\IsDueVoterInterface: class: Synolia\SyliusSchedulerCommandPlugin\Voter\IsDueVoter arguments: