Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / calendar / parser / data / PhutilCalendarDateTime.php
blobf9bf5a07a4cf82c710c1cc8429282076562caf46
1 <?php
3 abstract class PhutilCalendarDateTime
4 extends Phobject {
6 private $viewerTimezone;
7 private $isAllDay = false;
9 public function setViewerTimezone($viewer_timezone) {
10 $this->viewerTimezone = $viewer_timezone;
11 return $this;
14 public function getViewerTimezone() {
15 return $this->viewerTimezone;
18 public function setIsAllDay($is_all_day) {
19 $this->isAllDay = $is_all_day;
20 return $this;
23 public function getIsAllDay() {
24 return $this->isAllDay;
27 public function getEpoch() {
28 $datetime = $this->newPHPDateTime();
29 return (int)$datetime->format('U');
32 public function getISO8601() {
33 $datetime = $this->newPHPDateTime();
35 if ($this->getIsAllDay()) {
36 return $datetime->format('Ymd');
37 } else if ($this->getTimezone()) {
38 // With a timezone, the event occurs at a specific second universally.
39 // We return the UTC representation of that point in time.
40 $datetime->setTimezone(new DateTimeZone('UTC'));
41 return $datetime->format('Ymd\\THis\\Z');
42 } else {
43 // With no timezone, events are "floating" and occur at local time.
44 // We return a representation without the "Z".
45 return $datetime->format('Ymd\\THis');
49 abstract public function newPHPDateTimeZone();
50 abstract public function newPHPDateTime();
51 abstract public function newAbsoluteDateTime();
53 abstract public function getTimezone();