/**
  * Renders value.
  * @param string $value
  * @return string
  */
 public function renderValue($value)
 {
     $value = strtotime($value);
     if ($value == ZurmoTimeZoneHelper::getTimeZoneOffset()) {
         return Zurmo::t('Core', '(None)');
     }
     $dateTime = date('Y-m-d H:i:s', $value);
     return DateTimeUtil::resolveTimeStampForDateTimeLocaleFormattedDisplay($dateTime);
 }
Exemplo n.º 2
0
 /**
  * Gets full calendar formatted date time.
  * @param string $dateTime
  * @return string formatted in datetime format required for full calendar widget
  */
 public static function getFullCalendarFormattedDateTimeElement($dateTime)
 {
     assert('is_string($dateTime)');
     //The reason its put because timezone can vary from -12:00 to +12:00 max so
     //if we offset the gmt date by timezoneoffset, on applying offset, correct results
     //would come.
     if (DateTimeUtil::isValidDbFormattedDate($dateTime)) {
         $dateTime = DateTimeUtil::convertDateToDateTimeByTimeZoneOffset($dateTime);
     }
     $dateTimeObject = new DateTime();
     $dateTimeObject->setTimestamp(strtotime($dateTime));
     $offset = ZurmoTimeZoneHelper::getTimeZoneOffset();
     if ($offset < 0) {
         $offset = abs($offset);
         $dateTimeObject->sub(new DateInterval('PT' . $offset . 'S'));
     } else {
         $dateTimeObject->add(new DateInterval('PT' . $offset . 'S'));
     }
     return $dateTimeObject->format('c');
 }
Exemplo n.º 3
0
 /**
  * Convert date to datetime by setting the h:i:s as offset hours, minutes and seconds.
  * @param string $date
  * @return string
  */
 public static function convertDateToDateTimeByTimeZoneOffset($date)
 {
     $offset = ZurmoTimeZoneHelper::getTimeZoneOffset();
     $absOffset = abs($offset);
     $hours = floor($absOffset / (60 * 60));
     $absOffset -= $hours * (60 * 60);
     $minutes = floor($absOffset / 60);
     $absOffset -= $minutes * 60;
     $seconds = floor($absOffset);
     $absOffset -= $seconds;
     $hours = $hours < 10 ? '0' . $hours : $hours;
     $minutes = $minutes < 10 ? '0' . $minutes : $minutes;
     $seconds = $seconds < 10 ? '0' . $seconds : $seconds;
     return $date . ' ' . $hours . ':' . $minutes . ':' . $seconds;
 }
Exemplo n.º 4
0
 public function testIsCurrentUsersTimeZoneConfirmed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $timeZoneHelper = new ZurmoTimeZoneHelper();
     $this->assertFalse($timeZoneHelper->isCurrentUsersTimeZoneConfirmed());
     $timeZoneHelper->confirmCurrentUsersTimeZone();
     $this->assertTrue($timeZoneHelper->isCurrentUsersTimeZoneConfirmed());
     Yii::app()->user->userModel = User::getByUsername('billy');
     $timeZoneHelper = new ZurmoTimeZoneHelper();
     $this->assertFalse($timeZoneHelper->isCurrentUsersTimeZoneConfirmed());
     $timeZoneHelper->confirmCurrentUsersTimeZone();
     $this->assertTrue($timeZoneHelper->isCurrentUsersTimeZoneConfirmed());
 }