TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Scheduler\CronCommand\CronCommand Class Reference

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

 $cronCommandSections
 
 $timestamp
 

Detailed Description

This class provides calculations for the cron command format.

Definition at line 20 of file CronCommand.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor

Parameters
string$cronCommandThe cron command can hold any combination documented as valid
bool | int$timestampOptional start time, used in unit tests
Returns

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()

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$timestampto test
Returns
bool TRUE if cron command conditions are met

Definition at line 156 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()

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 127 of file CronCommand.php.

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

◆ getTimestamp()

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

Get next timestamp

Returns
int Unix timestamp

Definition at line 116 of file CronCommand.php.

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

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

◆ isInCommandList()

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 188 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()

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

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

Parameters
int$timestampto test
Returns
bool TRUE if cron command conditions are met

Definition at line 138 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()

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$timestampUnix timestamp
Returns
int Number of seconds of day

Definition at line 211 of file CronCommand.php.

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

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

◆ roundTimestamp()

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

Round a timestamp down to full minute.

Parameters
int$timestampUnix timestamp
Returns
int Rounded timestamp

Definition at line 226 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. Allowed are comma separated lists of integers and the character '*'

field lower and upper bound


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

Definition at line 36 of file CronCommand.php.

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

◆ $timestamp

TYPO3\CMS\Scheduler\CronCommand\CronCommand::$timestamp
protected

Timestamp of next execution date. This value starts with 'now + 1 minute' if not set externally by unit tests. After a call to calculateNextValue() it holds the timestamp of the next execution date which matches the cron command restrictions.

Definition at line 44 of file CronCommand.php.

Referenced by TYPO3\CMS\Scheduler\CronCommand\CronCommand\__construct(), TYPO3\CMS\Scheduler\CronCommand\CronCommand\dayMatchesCronCommand(), TYPO3\CMS\Scheduler\CronCommand\CronCommand\getTimestamp(), TYPO3\CMS\Scheduler\CronCommand\CronCommand\minuteAndHourMatchesCronCommand(), TYPO3\CMS\Scheduler\CronCommand\CronCommand\numberOfSecondsInDay(), and TYPO3\CMS\Scheduler\CronCommand\CronCommand\roundTimestamp().