‪TYPO3CMS  ‪main
TYPO3\CMS\Scheduler\CronCommand\CronCommand Class Reference

Public Member Functions

 __construct ($cronCommand, $timestamp=false)
 
 calculateNextValue ()
 
int getTimestamp ()
 
array getCronCommandSections ()
 

Protected Member Functions

bool minuteAndHourMatchesCronCommand ($timestamp)
 
bool dayMatchesCronCommand ($timestamp)
 
bool isInCommandList ($commandExpression, $numberToMatch)
 
int numberOfSecondsInDay ($timestamp)
 
int roundTimestamp (int $timestamp)
 

Protected Attributes

array $cronCommandSections
 
int $timestamp
 

Detailed Description

This class provides calculations for the cron command format.

Definition at line 23 of file CronCommand.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Scheduler\CronCommand\CronCommand::__construct (   $cronCommand,
  $timestamp = false 
)

Constructor

Parameters
string$cronCommand‪The cron command can hold any combination documented as valid
bool | int$timestamp‪Optional start time, used in unit tests

Definition at line 54 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$timestamp, TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand\normalize(), TYPO3\CMS\Scheduler\CronCommand\CronCommand\roundTimestamp(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Member Function Documentation

◆ calculateNextValue()

◆ dayMatchesCronCommand()

bool TYPO3\CMS\Scheduler\CronCommand\CronCommand::dayMatchesCronCommand (   $timestamp)
protected

Determine if current timestamp matches day of month, month and day of week cron command restriction

Parameters
int$timestamp‪to test
Returns
‪bool TRUE if cron command conditions are met

Definition at line 154 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$timestamp, and TYPO3\CMS\Scheduler\CronCommand\CronCommand\isInCommandList().

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\calculateNextValue().

◆ getCronCommandSections()

array TYPO3\CMS\Scheduler\CronCommand\CronCommand::getCronCommandSections ( )

Get cron command sections. Array of strings, each containing either a list of comma separated integers or *

Returns
‪array command sections:

Definition at line 125 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$cronCommandSections.

◆ getTimestamp()

int TYPO3\CMS\Scheduler\CronCommand\CronCommand::getTimestamp ( )

Get next timestamp

Returns
‪int Unix timestamp

Definition at line 113 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$timestamp.

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\calculateNextValue().

◆ isInCommandList()

bool TYPO3\CMS\Scheduler\CronCommand\CronCommand::isInCommandList (   $commandExpression,
  $numberToMatch 
)
protected

Determine if a given number validates a cron command section. The given cron command must be a 'normalized' list with only comma separated integers or '*'

Parameters
string$commandExpression‪cron command
int$numberToMatch‪number to look up
Returns
‪bool TRUE if number is in list

Definition at line 186 of file CronCommand.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\inList().

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\dayMatchesCronCommand(), and TYPO3\CMS\Scheduler\CronCommand\CronCommand\minuteAndHourMatchesCronCommand().

◆ minuteAndHourMatchesCronCommand()

bool TYPO3\CMS\Scheduler\CronCommand\CronCommand::minuteAndHourMatchesCronCommand (   $timestamp)
protected

Determine if current timestamp matches minute and hour cron command restriction.

Parameters
int$timestamp‪to test
Returns
‪bool TRUE if cron command conditions are met

Definition at line 136 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$timestamp, and TYPO3\CMS\Scheduler\CronCommand\CronCommand\isInCommandList().

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\calculateNextValue().

◆ numberOfSecondsInDay()

int TYPO3\CMS\Scheduler\CronCommand\CronCommand::numberOfSecondsInDay (   $timestamp)
protected

Helper method to calculate number of seconds in a day.

This is not always 86400 (60*60*24) and depends on the timezone: Some countries like Germany have a summertime / wintertime switch, on every last sunday in march clocks are forwarded by one hour (set from 2:00 to 3:00), and on last sunday of october they are set back one hour (from 3:00 to 2:00). This shortens and lengthens the length of a day by one hour.

Parameters
int$timestamp‪Unix timestamp
Returns
‪int Number of seconds of day

Definition at line 208 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$timestamp.

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\calculateNextValue().

◆ roundTimestamp()

int TYPO3\CMS\Scheduler\CronCommand\CronCommand::roundTimestamp ( int  $timestamp)
protected

Round a timestamp down to full minute.

Parameters
int$timestamp‪Unix timestamp
Returns
‪int Rounded timestamp

Definition at line 223 of file CronCommand.php.

References TYPO3\CMS\Scheduler\CronCommand\CronCommand\$timestamp.

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\__construct().

Member Data Documentation

◆ $cronCommandSections

array TYPO3\CMS\Scheduler\CronCommand\CronCommand::$cronCommandSections
protected

Normalized sections of the cron command. Comma separated lists of integers and the character '*' are allowed.

field lower and upper bound


minute 0-59 hour 0-23 day of month 1-31 month 1-12 day of week 1-7

$cronCommandSections

Definition at line 38 of file CronCommand.php.

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\getCronCommandSections().

◆ $timestamp