/** * @dataProvider dataProviderForTestResolveNewTimeStampForDuration */ public function testResolveNewTimeStampForDuration($initialTimeStamp, $durationInterval, $durationSign, $durationType, $expectedTimeStamp) { $timeZone = date_default_timezone_get(); date_default_timezone_set('America/Chicago'); //Test using an alternative time zone from GMT $this->assertEquals($expectedTimeStamp, TimeDurationUtil::resolveNewTimeStampForDuration($initialTimeStamp, $durationInterval, $durationSign, $durationType)); date_default_timezone_set($timeZone); }
protected function getDurationTypeDropDownArray() { if ($this->model->getValueEvaluationType() == 'Date') { return TimeDurationUtil::getDateOnlyValueAndLabels(); } elseif ($this->model->getValueEvaluationType() == 'DateTime') { return TimeDurationUtil::getValueAndLabels(); } else { throw new NotSupportedException(); } }
protected static function renderExtraInfoContent(Autoresponder $autoresponder) { $operationValuesAndLabels = Autoresponder::getOperationTypeDropDownArray(); $durationTypeValueAndLabels = TimeDurationUtil::getValueAndLabels(); if (!isset($operationValuesAndLabels[$autoresponder->operationType])) { return; } if (!isset($durationTypeValueAndLabels[$autoresponder->fromOperationDurationType])) { return; } if ($autoresponder->fromOperationDurationInterval == 0) { return Zurmo::t('AutorespondersModule', 'Send immediately after {operation}', array('{operation}' => $operationValuesAndLabels[$autoresponder->operationType])); } else { $content = Zurmo::t('AutorespondersModule', 'Send {interval} {type} after {operation}', array('{interval}' => $autoresponder->fromOperationDurationInterval, '{type}' => $durationTypeValueAndLabels[$autoresponder->fromOperationDurationType], '{operation}' => $operationValuesAndLabels[$autoresponder->operationType])); return $content; } }
/** * @param integer $initialTimeStamp * @return integer timestamp based on durationInterval, durationSign, and durationType */ public function resolveNewTimeStampForDuration($initialTimeStamp) { assert('is_int($initialTimeStamp)'); return TimeDurationUtil::resolveNewTimeStampForDuration($initialTimeStamp, (int) $this->durationInterval, $this->durationSign, $this->durationType); }
protected function getDurationTypeDropDownArray() { return TimeDurationUtil::getValueAndLabels(); }
/** * @param integer $initialTimeStamp * @return integer timestamp based on durationInterval, durationSign, and durationType */ public function resolveNewTimeStampForDuration($initialTimeStamp) { assert('is_int($initialTimeStamp)'); return TimeDurationUtil::resolveNewTimeStampForDuration($initialTimeStamp, (int) $this->fromOperationDurationInterval, TimeDurationUtil::DURATION_SIGN_POSITIVE, $this->fromOperationDurationType); }
/** * Resolve durationSign based on value type * MixedDateTypesTriggerForWorkflowFormAttributeMappingRules::TYPE_AT_LEAST_X_AFTER_TRIGGERED_DATE * or * MixedDateTypesTriggerForWorkflowFormAttributeMappingRules::TYPE_AT_LEAST_X_BEFORE_TRIGGERED_DATE * @param integer $initialTimeStamp * @return integer timestamp based on thirdValueDurationInterval, valueType, and thirdValueDurationType */ public function resolveNewTimeStampForThirdValueDuration($initialTimeStamp) { assert('is_int($initialTimeStamp)'); if ($this->valueType == MixedDateTypesTriggerForWorkflowFormAttributeMappingRules::TYPE_AT_LEAST_X_AFTER_TRIGGERED_DATE || $this->valueType == MixedDateTypesTriggerForWorkflowFormAttributeMappingRules::TYPE_LESS_THAN_X_AFTER_TRIGGERED_DATE) { $durationSign = TimeDurationUtil::DURATION_SIGN_POSITIVE; } else { $durationSign = TimeDurationUtil::DURATION_SIGN_NEGATIVE; } return TimeDurationUtil::resolveNewTimeStampForDuration($initialTimeStamp, (int) $this->thirdValueDurationInterval, $durationSign, $this->thirdValueDurationType); }