mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Provide start/end date time via Conduit for Calendar
Summary: Fixes T11706. I think this approach (roughly: provide the information in a few different formats) is generally reasonable, and should let clients choose how much date/time magic they want to do. Test Plan: Called `calenadar.event.search`, viewed results. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11706 Differential Revision: https://secure.phabricator.com/D16688
This commit is contained in:
parent
6d525848bf
commit
d79972ecb3
1 changed files with 36 additions and 0 deletions
|
@ -1056,13 +1056,27 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
|||
->setKey('description')
|
||||
->setType('string')
|
||||
->setDescription(pht('The event description.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('startDateTime')
|
||||
->setType('datetime')
|
||||
->setDescription(pht('Start date and time of the event.')),
|
||||
id(new PhabricatorConduitSearchFieldSpecification())
|
||||
->setKey('endDateTime')
|
||||
->setType('datetime')
|
||||
->setDescription(pht('End date and time of the event.')),
|
||||
);
|
||||
}
|
||||
|
||||
public function getFieldValuesForConduit() {
|
||||
$start_datetime = $this->newStartDateTime();
|
||||
$end_datetime = $this->newEndDateTime();
|
||||
|
||||
return array(
|
||||
'name' => $this->getName(),
|
||||
'description' => $this->getDescription(),
|
||||
'isAllDay' => $this->getIsAllDay(),
|
||||
'startDateTime' => $this->getConduitDateTime($start_datetime),
|
||||
'endDateTime' => $this->getConduitDateTime($end_datetime),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1070,4 +1084,26 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
|||
return array();
|
||||
}
|
||||
|
||||
private function getConduitDateTime($datetime) {
|
||||
if (!$datetime) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$epoch = $datetime->getEpoch();
|
||||
|
||||
// TODO: Possibly pass the actual viewer in from the Conduit stuff, or
|
||||
// retain it when setting the viewer timezone?
|
||||
$viewer = id(new PhabricatorUser())
|
||||
->overrideTimezoneIdentifier($this->viewerTimezone);
|
||||
|
||||
return array(
|
||||
'epoch' => $epoch,
|
||||
'display' => array(
|
||||
'default' => phabricator_datetime($epoch, $viewer),
|
||||
),
|
||||
'iso8601' => $datetime->getISO8601(),
|
||||
'timezone' => $this->viewerTimezone,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue