public function removeViewerTimezone(PhabricatorUser $viewer)
 {
     if (!$this->appliedViewer) {
         throw new Exception(pht('Viewer timezone is not applied!'));
     }
     if ($viewer->getPHID() != $this->appliedViewer->getPHID()) {
         throw new Exception(pht('Removed viewer must match applied viewer!'));
     }
     $this->appliedViewer = null;
     if (!$this->getIsAllDay()) {
         return $this;
     }
     $zone = $viewer->getTimeZone();
     $this->setDateFrom($this->getDateEpochForTimeZone($this->getDateFrom(), $zone, 'Y-m-d', null, new DateTimeZone('Pacific/Kiritimati')));
     $this->setDateTo($this->getDateEpochForTimeZone($this->getDateTo(), $zone, 'Y-m-d', '+1 day', new DateTimeZone('Pacific/Midway')));
     return $this;
 }
示例#2
0
 public static function getDateTimeFromEpoch($epoch, PhabricatorUser $viewer)
 {
     $datetime = new DateTime('@' . $epoch);
     $datetime->setTimeZone($viewer->getTimeZone());
     return $datetime;
 }
 public function applyViewerTimezone(PhabricatorUser $viewer)
 {
     if (!$this->getIsAllDay()) {
         $this->viewerDateFrom = $this->getDateFrom();
         $this->viewerDateTo = $this->getDateTo();
     } else {
         $zone = $viewer->getTimeZone();
         $this->viewerDateFrom = $this->getDateEpochForTimezone($this->getAllDayDateFrom(), new DateTimeZone('UTC'), 'Y-m-d', null, $zone);
         $this->viewerDateTo = $this->getDateEpochForTimezone($this->getAllDayDateTo(), new DateTimeZone('UTC'), 'Y-m-d 23:59:00', null, $zone);
     }
     return $this;
 }