Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96074898
PhutilCalendarRelativeDateTime.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 22, 08:50
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 24, 08:50 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23113693
Attached To
rPHU libphutil
PhutilCalendarRelativeDateTime.php
View Options
<?php
final
class
PhutilCalendarRelativeDateTime
extends
PhutilCalendarProxyDateTime
{
private
$duration
;
public
function
setOrigin
(
PhutilCalendarDateTime
$origin
)
{
return
$this
->
setProxy
(
$origin
);
}
public
function
getOrigin
()
{
return
$this
->
getProxy
();
}
public
function
setDuration
(
PhutilCalendarDuration
$duration
)
{
$this
->
duration
=
$duration
;
return
$this
;
}
public
function
getDuration
()
{
return
$this
->
duration
;
}
public
function
newPHPDateTime
()
{
$datetime
=
parent
::
newPHPDateTime
();
$duration
=
$this
->
getDuration
();
if
(
$duration
->
getIsNegative
())
{
$sign
=
'-'
;
}
else
{
$sign
=
'+'
;
}
$map
=
array
(
'weeks'
=>
$duration
->
getWeeks
(),
'days'
=>
$duration
->
getDays
(),
'hours'
=>
$duration
->
getHours
(),
'minutes'
=>
$duration
->
getMinutes
(),
'seconds'
=>
$duration
->
getSeconds
(),
);
foreach
(
$map
as
$unit
=>
$value
)
{
if
(!
$value
)
{
continue
;
}
$datetime
->
modify
(
"{$sign}{$value} {$unit}"
);
}
return
$datetime
;
}
public
function
newAbsoluteDateTime
()
{
$clone
=
clone
$this
;
if
(
$clone
->
getTimezone
())
{
$clone
->
setViewerTimezone
(
null
);
}
$datetime
=
$clone
->
newPHPDateTime
();
return
id
(
new
PhutilCalendarAbsoluteDateTime
())
->
setYear
((
int
)
$datetime
->
format
(
'Y'
))
->
setMonth
((
int
)
$datetime
->
format
(
'm'
))
->
setDay
((
int
)
$datetime
->
format
(
'd'
))
->
setHour
((
int
)
$datetime
->
format
(
'H'
))
->
setMinute
((
int
)
$datetime
->
format
(
'i'
))
->
setSecond
((
int
)
$datetime
->
format
(
's'
))
->
setIsAllDay
(
$clone
->
getIsAllDay
())
->
setTimezone
(
$clone
->
getTimezone
())
->
setViewerTimezone
(
$this
->
getViewerTimezone
());
}
}
Event Timeline
Log In to Comment