Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/parser/data/PhutilCalendarDateTime.php
12262 views
1
<?php
2
3
abstract class PhutilCalendarDateTime
4
extends Phobject {
5
6
private $viewerTimezone;
7
private $isAllDay = false;
8
9
public function setViewerTimezone($viewer_timezone) {
10
$this->viewerTimezone = $viewer_timezone;
11
return $this;
12
}
13
14
public function getViewerTimezone() {
15
return $this->viewerTimezone;
16
}
17
18
public function setIsAllDay($is_all_day) {
19
$this->isAllDay = $is_all_day;
20
return $this;
21
}
22
23
public function getIsAllDay() {
24
return $this->isAllDay;
25
}
26
27
public function getEpoch() {
28
$datetime = $this->newPHPDateTime();
29
return (int)$datetime->format('U');
30
}
31
32
public function getISO8601() {
33
$datetime = $this->newPHPDateTime();
34
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');
46
}
47
}
48
49
abstract public function newPHPDateTimeZone();
50
abstract public function newPHPDateTime();
51
abstract public function newAbsoluteDateTime();
52
53
abstract public function getTimezone();
54
}
55
56