1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-18 18:51:12 +01:00

Make calendar intepret all-day dates in a more consistent way

Summary:
In ICS, an event on "Nov 1" starts on "2016-11-01" and ends on "2016-11-02".

This is convenient for computers, but this isn't what users expect to enter in date controls. They expect to enter "nov 1" to "Nov 1" for a one-day, all-day event. This is consistent with other applications.

Store the value the user entered, but treat it as the first second of the next day when actually using it if the event is an all day event.

Test Plan:
Mucked around with multi-day all-day events, recurring all-day events, imports, etc. Couldn't catch any weird/unintuitive stuff anymore offhand.

(Previously, entering "Nov 1" to "Nov 2" created a one-day event, which was unclear.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D16777
This commit is contained in:
epriestley 2016-10-31 11:51:31 -07:00
parent f7b0c09ac4
commit 8e5437226f
3 changed files with 22 additions and 3 deletions

View file

@ -119,7 +119,7 @@ final class PhabricatorCalendarEventEditEngine
->setDescription(pht('End time of the event.'))
->setConduitDescription(pht('Change the end time of the event.'))
->setConduitTypeDescription(pht('New event end time.'))
->setValue($object->getEndDateTimeEpoch()),
->setValue($object->newEndDateTimeForEdit()->getEpoch()),
id(new PhabricatorBoolEditField())
->setKey('cancelled')
->setOptions(pht('Active'), pht('Cancelled'))

View file

@ -857,7 +857,7 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return $this->newStartDateTime()->getEpoch();
}
public function newEndDateTime() {
public function newEndDateTimeForEdit() {
$datetime = $this->getParameter('endDateTime');
if ($datetime) {
return $this->newDateTimeFromDictionary($datetime);
@ -867,6 +867,25 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return $this->newDateTimeFromEpoch($epoch);
}
public function newEndDateTime() {
$datetime = $this->newEndDateTimeForEdit();
// If this is an all day event, we move the end date time forward to the
// first second of the following day. This is consistent with what users
// expect: an all day event from "Nov 1" to "Nov 1" lasts the entire day.
if ($this->getIsAllDay()) {
$datetime = $datetime
->newAbsoluteDateTime()
->setHour(0)
->setMinute(0)
->setSecond(0)
->newRelativeDateTime('P1D')
->newAbsoluteDateTime();
}
return $datetime;
}
public function getEndDateTimeEpoch() {
return $this->newEndDateTime()->getEpoch();
}

View file

@ -7,7 +7,7 @@ final class PhabricatorCalendarEventEndDateTransaction
public function generateOldValue($object) {
// TODO: Upgrade this.
return $object->getEndDateTimeEpoch();
return $object->newEndDateTimeForEdit()->getEpoch();
}
public function applyInternalEffects($object, $value) {