*/
abstract class CronjobUtil {
/**
- * Set to true if day of month is '*'
- *
+ * indicates if day of month is restricted (not '*')
* @var boolean
*/
protected static $domRestricted = false;
/**
- * Set to true if day of week is '*'
- *
+ * indicates if day of week is restricted (not '*')
* @var boolean
*/
protected static $dowRestricted = false;
/**
- * Result date
- *
+ * result date
* @var array<integer>
*/
protected static $result = array();
/**
- * Time based used as reference for finding the next time of execution
- *
+ * time base used as reference for finding the next execution time
* @var integer
*/
protected static $timeBase = 0;
/**
- * Valid ranges for each known field. Note that the range for
- * 'day of month' is missing, since it varies on each month.
- *
- * @var array<array>
+ * valid ranges for each known field (range for 'day of month' is missing
+ * since it varies from month to month)
+ * @var array<integer>
*/
public static $ranges = array(
'minute' => array(0, 59),
self::$domRestricted = ($dom != '*') ? true : false;
self::$dowRestricted = ($dow != '*') ? true : false;
+ $dayNames = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
+ $monthNames = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
+
// calculate values based upon each expression
+ $values = array();
foreach ($fields as $fieldName => $fieldValue) {
$fieldValue = StringUtil::toLowerCase($fieldValue);
switch ($fieldName) {
case 'dow':
- $dayNames = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
-
if (strlen($fieldValue) == 3 && in_array($fieldName, $dayNames)) {
- $fieldValue = $monthNames[$fieldValue];
+ $fieldValue = $dayNames[$fieldValue];
}
// When specifying day of week, both day 0 and day 7
// will be considered Sunday. -- crontab(5)
break;
case 'month':
- $monthNames = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
-
if (strlen($fieldValue) == 3 && in_array($fieldValue, $monthNames)) {
$fieldValue = $monthNames[$fieldValue] + 1;
}
/**
* Returns a formatted date.
*
- * @param DateTime $time
- * @param string $format
- * @param Language $language
- * @param User $user
+ * @param \DateTime $time
+ * @param string $format
+ * @param wcf\data\language\Language $language
+ * @param wcf\data\user\User $user
*/
public static function format(\DateTime $time = null, $format = null, Language $language = null, User $user = null) {
// get default values
*
* @param string $date
* @param string $format
- * @param Language $language
+ * @param wcf\data\language\Language $language
*/
public static function localizeDate($date, $format, Language $language) {
if ($language->languageCode != 'en') {
* Creates a DateTime object with the given unix timestamp.
*
* @param integer $timestamp
- * @return DateTime
+ * @return \DateTime
*/
public static function getDateTimeByTimestamp($timestamp) {
return new \DateTime('@'.$timestamp);