Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15391267
D16662.id40114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D16662.id40114.diff
View Options
diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php
@@ -27,8 +27,8 @@
$page_title = $monogram.' '.$event->getName();
$crumbs = $this->buildApplicationCrumbs();
- $start = new DateTime('@'.$event->getViewerDateFrom());
- $start->setTimeZone($viewer->getTimeZone());
+ $start = $event->newStartDateTime()
+ ->newPHPDateTime();
$crumbs->addTextCrumb(
$start->format('F Y'),
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php
@@ -155,6 +155,13 @@
}
if ($this->getIsCreate() || $object->getIsRecurring()) {
+ $until_datetime = $object->newUntilDateTime();
+ if ($until_datetime) {
+ $until_epoch = $until_datetime->getEpoch();
+ } else {
+ $until_epoch = null;
+ }
+
$fields[] = id(new PhabricatorEpochEditField())
->setAllowNull(true)
->setKey('until')
@@ -164,7 +171,7 @@
->setDescription(pht('Last instance of the event.'))
->setConduitDescription(pht('Change when the event repeats until.'))
->setConduitTypeDescription(pht('New final event time.'))
- ->setValue($object->getRecurrenceEndDate());
+ ->setValue($until_epoch);
}
$fields[] = id(new PhabricatorBoolEditField())
@@ -186,7 +193,7 @@
->setDescription(pht('Start time of the event.'))
->setConduitDescription(pht('Change the start time of the event.'))
->setConduitTypeDescription(pht('New event start time.'))
- ->setValue($object->getViewerDateFrom());
+ ->setValue($object->getStartDateTimeEpoch());
$fields[] = id(new PhabricatorEpochEditField())
->setKey('end')
@@ -196,7 +203,7 @@
->setDescription(pht('End time of the event.'))
->setConduitDescription(pht('Change the end time of the event.'))
->setConduitTypeDescription(pht('New event end time.'))
- ->setValue($object->getViewerDateTo());
+ ->setValue($object->getEndDateTimeEpoch());
$fields[] = id(new PhabricatorIconSetEditField())
->setKey('icon')
diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php
@@ -99,7 +99,7 @@
protected function getPagingValueMap($cursor, array $keys) {
$event = $this->loadCursorObject($cursor);
return array(
- 'start' => $event->getViewerDateFrom(),
+ 'start' => $event->getStartDateTimeEpoch(),
'id' => $event->getID(),
);
}
@@ -177,9 +177,9 @@
$modify_key = '+1 '.$frequency;
if (($this->rangeBegin !== null) &&
- ($this->rangeBegin > $event->getViewerDateFrom())) {
+ ($this->rangeBegin > $event->getStartDateTimeEpoch())) {
$max_date = $this->rangeBegin - $duration;
- $date = $event->getViewerDateFrom();
+ $date = $event->getStartDateTimeEpoch();
$datetime = PhabricatorTime::getDateTimeFromEpoch($date, $viewer);
while ($date < $max_date) {
@@ -191,7 +191,7 @@
$start = $this->rangeBegin;
} else {
- $start = $event->getViewerDateFrom() - $duration;
+ $start = $event->getStartDateTimeEpoch() - $duration;
}
$date = $start;
@@ -238,9 +238,9 @@
if ($raw_limit) {
if (count($events) > $raw_limit) {
- $events = msort($events, 'getViewerDateFrom');
+ $events = msort($events, 'getStartDateTimeEpoch');
$events = array_slice($events, 0, $raw_limit, true);
- $enforced_end = last($events)->getViewerDateFrom();
+ $enforced_end = last($events)->getStartDateTimeEpoch();
}
}
}
@@ -308,7 +308,7 @@
}
}
- $events = msort($events, 'getViewerDateFrom');
+ $events = msort($events, 'getStartDateTimeEpoch');
return $events;
}
@@ -500,7 +500,7 @@
}
}
- $events = msort($events, 'getViewerDateFrom');
+ $events = msort($events, 'getStartDateTimeEpoch');
return $events;
}
@@ -510,8 +510,8 @@
$range_end = $this->rangeEnd;
foreach ($events as $key => $event) {
- $event_start = $event->getViewerDateFrom();
- $event_end = $event->getViewerDateTo();
+ $event_start = $event->getStartDateTimeEpoch();
+ $event_end = $event->getEndDateTimeEpoch();
if ($range_start && $event_end < $range_start) {
unset($events[$key]);
diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
@@ -343,8 +343,8 @@
$month_view->setUser($viewer);
foreach ($events as $event) {
- $epoch_min = $event->getViewerDateFrom();
- $epoch_max = $event->getViewerDateTo();
+ $epoch_min = $event->getStartDateTimeEpoch();
+ $epoch_max = $event->getEndDateTimeEpoch();
$event_view = id(new AphrontCalendarEventView())
->setHostPHID($event->getHostPHID())
@@ -408,8 +408,8 @@
$event,
PhabricatorPolicyCapability::CAN_EDIT);
- $epoch_min = $event->getViewerDateFrom();
- $epoch_max = $event->getViewerDateTo();
+ $epoch_min = $event->getStartDateTimeEpoch();
+ $epoch_max = $event->getEndDateTimeEpoch();
$status_icon = $event->getDisplayIcon($viewer);
$status_color = $event->getDisplayIconColor($viewer);
diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
--- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -49,8 +49,6 @@
private $parentEvent = self::ATTACHABLE;
private $invitees = self::ATTACHABLE;
- private $viewerDateFrom;
- private $viewerDateTo;
private $viewerTimezone;
// Frequency Constants
@@ -273,46 +271,8 @@
return $ghost;
}
- public function getViewerDateFrom() {
- if ($this->viewerDateFrom === null) {
- throw new PhutilInvalidStateException('applyViewerTimezone');
- }
-
- return $this->viewerDateFrom;
- }
-
- public function getViewerDateTo() {
- if ($this->viewerDateTo === null) {
- throw new PhutilInvalidStateException('applyViewerTimezone');
- }
-
- return $this->viewerDateTo;
- }
-
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);
- }
-
$this->viewerTimezone = $viewer->getTimezoneIdentifier();
-
return $this;
}
@@ -407,7 +367,9 @@
* @return int Event start date for availability caches.
*/
public function getDateFromForCache() {
- return ($this->getViewerDateFrom() - phutil_units('15 minutes in seconds'));
+ $epoch = $this->getStartDateTimeEpoch();
+ $window = phutil_units('15 minutes in seconds');
+ return ($epoch - $window);
}
protected function getConfiguration() {
@@ -593,14 +555,12 @@
PhabricatorUser $viewer,
$show_end) {
- if ($show_end) {
- $min_date = PhabricatorTime::getDateTimeFromEpoch(
- $this->getViewerDateFrom(),
- $viewer);
+ $start = $this->newStartDateTime();
+ $end = $this->newEndDateTime();
- $max_date = PhabricatorTime::getDateTimeFromEpoch(
- $this->getViewerDateTo(),
- $viewer);
+ if ($show_end) {
+ $min_date = $start->newPHPDateTime();
+ $max_date = $end->newPHPDateTime();
$min_day = $min_date->format('Y m d');
$max_day = $max_date->format('Y m d');
@@ -610,8 +570,8 @@
$show_end_date = false;
}
- $min_epoch = $this->getViewerDateFrom();
- $max_epoch = $this->getViewerDateTo();
+ $min_epoch = $start->getEpoch();
+ $max_epoch = $end->getEpoch();
if ($this->getIsAllDay()) {
if ($show_end_date) {
@@ -803,6 +763,10 @@
return $this->newDateTimeFromEpoch($epoch);
}
+ public function getStartDateTimeEpoch() {
+ return $this->newStartDateTime()->getEpoch();
+ }
+
public function newEndDateTime() {
$datetime = $this->getParameter('endDateTime');
if ($datetime) {
@@ -813,6 +777,10 @@
return $this->newDateTimeFromEpoch($epoch);
}
+ public function getEndDateTimeEpoch() {
+ return $this->newEndDateTime()->getEpoch();
+ }
+
public function newUntilDateTime() {
$datetime = $this->getParameter('untilDateTime');
if ($datetime) {
diff --git a/src/applications/people/controller/PhabricatorPeopleProfileViewController.php b/src/applications/people/controller/PhabricatorPeopleProfileViewController.php
--- a/src/applications/people/controller/PhabricatorPeopleProfileViewController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfileViewController.php
@@ -205,8 +205,8 @@
$event,
PhabricatorPolicyCapability::CAN_EDIT);
- $epoch_min = $event->getViewerDateFrom();
- $epoch_max = $event->getViewerDateTo();
+ $epoch_min = $event->getStartDateTimeEpoch();
+ $epoch_max = $event->getEndDateTimeEpoch();
$event_view = id(new AphrontCalendarEventView())
->setCanEdit($can_edit)
diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php
--- a/src/applications/people/query/PhabricatorPeopleQuery.php
+++ b/src/applications/people/query/PhabricatorPeopleQuery.php
@@ -432,7 +432,7 @@
while (true) {
foreach ($events as $event) {
$from = $event->getDateFromForCache();
- $to = $event->getViewerDateTo();
+ $to = $event->getEndDateTimeEpoch();
if (($from <= $cursor) && ($to > $cursor)) {
$cursor = $to;
continue 2;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 9:08 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706003
Default Alt Text
D16662.id40114.diff (10 KB)
Attached To
Mode
D16662: Remove "viewerDateFrom" / "viewerDateTo" in favor of CalendarDateTime methods
Attached
Detach File
Event Timeline
Log In to Comment