TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Scheduler\CronCommand\CronCommand Class Reference
Inheritance diagram for TYPO3\CMS\Scheduler\CronCommand\CronCommand:
tx_scheduler_CronCmd

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 file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! This class provides calculations for the cron command format.

Author
Markus Friedrich marku.nosp@m.s.fr.nosp@m.iedri.nosp@m.ch@d.nosp@m.kd.de
Christian Kuhn lolli.nosp@m.@sch.nosp@m.warzb.nosp@m.u.ch

Definition at line 22 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 56 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
integer$timestampto test
Returns
boolean TRUE if cron command conditions are met

Definition at line 152 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 125 of file CronCommand.php.

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

◆ getTimestamp()

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

◆ 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
integer$numberToMatch,number to look up
Returns
boolean TRUE if number is in list

Definition at line 183 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
integer$timestampto test
Returns
boolean TRUE if cron command conditions are met

Definition at line 135 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
integer$timestampUnix timestamp
Returns
integer Number of seconds of day

Definition at line 205 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
integer$timestampUnix timestamp
Returns
integer Rounded timestamp

Definition at line 219 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 38 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 46 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().