/**
  * @param string $attribute
  * @return string
  */
 protected function resolveTimeZoneAdjustmentForACalculatedDateTimeModifier($attribute)
 {
     $resolvedAttribute = $this->modelToReportAdapter->resolveRealAttributeName($attribute);
     if ($this->modelToReportAdapter->getRealModelAttributeType($resolvedAttribute) == 'DateTime') {
         return DatabaseCompatibilityUtil::makeTimeZoneAdjustmentContent();
     }
 }
Пример #2
0
 /**
  * @return string
  */
 protected function resolveTimeZoneAdjustmentForACalculatedDateTimeModifier()
 {
     $attributeType = ModelAttributeToMixedTypeUtil::getType($this->modelAttributeToDataProviderAdapter->getModel(), $this->modelAttributeToDataProviderAdapter->getAttribute());
     if ($attributeType == 'DateTime') {
         return DatabaseCompatibilityUtil::makeTimeZoneAdjustmentContent();
     }
 }
 public static function makeYearModifierString($tableName, $columnName, $adjustForTimeZone = false)
 {
     assert('is_string($tableName)');
     assert('is_string($columnName)');
     assert('is_bool($adjustForTimeZone)');
     $quote = DatabaseCompatibilityUtil::getQuote();
     $queryString = "{$quote}{$tableName}{$quote}.{$quote}{$columnName}{$quote}";
     if ($adjustForTimeZone) {
         $queryString .= DatabaseCompatibilityUtil::makeTimeZoneAdjustmentContent();
     }
     return "year({$queryString})";
 }
 public function testMakeTimeZoneAdjustmentContent()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $this->assertNull(DatabaseCompatibilityUtil::makeTimeZoneAdjustmentContent());
     $tempTimeZone = Yii::app()->user->userModel->timeZone;
     Yii::app()->user->userModel->timeZone = 'America/Chicago';
     //Deal with daylight savings time.
     $timeZoneObject = new DateTimeZone(Yii::app()->user->userModel->timeZone);
     $offsetInSeconds = $timeZoneObject->getOffset(new DateTime());
     $this->assertTrue($offsetInSeconds == -18000 || $offsetInSeconds == -21600);
     $compareContent = ' - INTERVAL ' . abs($offsetInSeconds) . ' SECOND';
     $this->assertEquals($compareContent, DatabaseCompatibilityUtil::makeTimeZoneAdjustmentContent());
     Yii::app()->user->userModel->timeZone = 'Asia/Tokyo';
     $compareContent = ' + INTERVAL 32400 SECOND';
     $this->assertEquals($compareContent, DatabaseCompatibilityUtil::makeTimeZoneAdjustmentContent());
     Yii::app()->user->userModel->timeZone = $tempTimeZone;
 }