Skip to content

Commit

Permalink
Add possibility of time date format 12/24
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilvestre authored Mar 13, 2024
1 parent 1d35dec commit 79d3dda
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Humanizer/CronExpressionHumanizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class CronExpressionHumanizer implements HumanizerInterface
{
public function __construct(private LocaleContextInterface $localeContext)
public function __construct(private LocaleContextInterface $localeContext, private bool $timeFormat24Hours = false)
{
}

Expand All @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: '../../*'
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 79d3dda

Please sign in to comment.