diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php index 93642a959c..63d33beab4 100644 --- a/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php +++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditEngine.php @@ -155,13 +155,6 @@ final class PhabricatorCalendarEventEditEngine } 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') @@ -171,7 +164,7 @@ final class PhabricatorCalendarEventEditEngine ->setDescription(pht('Last instance of the event.')) ->setConduitDescription(pht('Change when the event repeats until.')) ->setConduitTypeDescription(pht('New final event time.')) - ->setValue($until_epoch); + ->setValue($object->getUntilDateTimeEpoch()); } $fields[] = id(new PhabricatorBoolEditField()) diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php index d87746f347..5dd9b463c6 100644 --- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php +++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php @@ -139,7 +139,7 @@ final class PhabricatorCalendarEventEditor WHERE phid IN (%Ls) AND availabilityCacheTTL >= %d', $user->getTableName(), $phids, - $object->getDateFromForCache()); + $object->getStartDateTimeEpochForCache()); } return $xactions; @@ -159,9 +159,9 @@ final class PhabricatorCalendarEventEditor $recurrence_end_xaction = PhabricatorCalendarEventUntilDateTransaction::TRANSACTIONTYPE; - $start_date = $object->getDateFrom(); - $end_date = $object->getDateTo(); - $recurrence_end = $object->getRecurrenceEndDate(); + $start_date = $object->getStartDateTimeEpoch(); + $end_date = $object->getEndDateTimeEpoch(); + $recurrence_end = $object->getUntilDateTimeEpoch(); $is_recurring = $object->getIsRecurring(); $errors = array(); diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index 6e4d0ce04e..2ddc71115f 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -184,7 +184,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO ->setDescription($parent->getDescription()); $sequence = $this->getSequenceIndex(); - $duration = $this->getDuration(); + $duration = $parent->getDuration(); $epochs = $parent->getSequenceIndexEpochs($actor, $sequence, $duration); $this @@ -277,7 +277,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO } public function getDuration() { - return $this->getDateTo() - $this->getDateFrom(); + return ($this->getEndDateTimeEpoch() - $this->getStartDateTimeEpoch()); } public function getDateEpochForTimezone( @@ -366,7 +366,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO * * @return int Event start date for availability caches. */ - public function getDateFromForCache() { + public function getStartDateTimeEpochForCache() { $epoch = $this->getStartDateTimeEpoch(); $window = phutil_units('15 minutes in seconds'); return ($epoch - $window); @@ -794,6 +794,16 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO return $this->newDateTimeFromEpoch($epoch); } + public function getUntilDateTimeEpoch() { + $datetime = $this->newUntilDateTime(); + + if (!$datetime) { + return null; + } + + return $datetime->getEpoch(); + } + public function newDuration() { return id(new PhutilCalendarDuration()) ->setSeconds($this->getDuration()); diff --git a/src/applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php index 91d9b396ff..2d5f10d290 100644 --- a/src/applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php +++ b/src/applications/calendar/xaction/PhabricatorCalendarEventEndDateTransaction.php @@ -6,7 +6,8 @@ final class PhabricatorCalendarEventEndDateTransaction const TRANSACTIONTYPE = 'calendar.enddate'; public function generateOldValue($object) { - return $object->getDateTo(); + // TODO: Upgrade this. + return $object->getEndDateTimeEpoch(); } public function applyInternalEffects($object, $value) { diff --git a/src/applications/calendar/xaction/PhabricatorCalendarEventStartDateTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarEventStartDateTransaction.php index 90e3b9c9c5..48318edf7e 100644 --- a/src/applications/calendar/xaction/PhabricatorCalendarEventStartDateTransaction.php +++ b/src/applications/calendar/xaction/PhabricatorCalendarEventStartDateTransaction.php @@ -6,7 +6,8 @@ final class PhabricatorCalendarEventStartDateTransaction const TRANSACTIONTYPE = 'calendar.startdate'; public function generateOldValue($object) { - return $object->getDateFrom(); + // TODO: Upgrade this. + return $object->getStartDateTimeEpoch(); } public function applyInternalEffects($object, $value) { diff --git a/src/applications/calendar/xaction/PhabricatorCalendarEventUntilDateTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarEventUntilDateTransaction.php index 4cffda8ff6..736ed13704 100644 --- a/src/applications/calendar/xaction/PhabricatorCalendarEventUntilDateTransaction.php +++ b/src/applications/calendar/xaction/PhabricatorCalendarEventUntilDateTransaction.php @@ -6,7 +6,8 @@ final class PhabricatorCalendarEventUntilDateTransaction const TRANSACTIONTYPE = 'calendar.recurrenceenddate'; public function generateOldValue($object) { - return $object->getRecurrenceEndDate(); + // TODO: Upgrade this. + return $object->getUntilDateTimeEpoch(); } public function applyInternalEffects($object, $value) { diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php index 5d5650c860..07fbc8b941 100644 --- a/src/applications/people/query/PhabricatorPeopleQuery.php +++ b/src/applications/people/query/PhabricatorPeopleQuery.php @@ -431,7 +431,7 @@ final class PhabricatorPeopleQuery // because of an event, we check again for events after that one ends. while (true) { foreach ($events as $event) { - $from = $event->getDateFromForCache(); + $from = $event->getStartDateTimeEpochForCache(); $to = $event->getEndDateTimeEpoch(); if (($from <= $cursor) && ($to > $cursor)) { $cursor = $to;