mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Use more CalendarDateTime and fewer epoch timestamps in Calendar
Summary: Ref T10747. Moves away from getDateFrom() / getDateTo() and makes a few more date/time methods more consistent. Test Plan: Created, edited, viewed events. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10747 Differential Revision: https://secure.phabricator.com/D16663
This commit is contained in:
parent
37f35e9ecc
commit
fae0ec9220
7 changed files with 25 additions and 19 deletions
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue