aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-04-25 08:52:50 +0200
committerMario Vavti <mario@mariovavti.com>2019-04-25 08:52:50 +0200
commite779335d060b3a51d6a144d23af4097ae6801473 (patch)
tree2427765313f715a0e5b48228abe5200cb82b787f /vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php
parente937e8fff96a935b14a479c062f6b0d00b90b99d (diff)
downloadvolse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.tar.gz
volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.tar.bz2
volse-hubzilla-e779335d060b3a51d6a144d23af4097ae6801473.zip
update composer libs
Diffstat (limited to 'vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php')
-rw-r--r--vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php145
1 files changed, 54 insertions, 91 deletions
diff --git a/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php b/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php
index d580d4f68..7eb3e0bb7 100644
--- a/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php
+++ b/vendor/sabre/vobject/lib/Property/ICalendar/DateTime.php
@@ -24,8 +24,8 @@ use Sabre\VObject\TimeZoneUtil;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class DateTime extends Property {
-
+class DateTime extends Property
+{
/**
* In case this is a multi-value property. This string will be used as a
* delimiter.
@@ -40,17 +40,14 @@ class DateTime extends Property {
* You may also specify DateTime objects here.
*
* @param array $parts
- *
- * @return void
*/
- function setParts(array $parts) {
-
+ public function setParts(array $parts)
+ {
if (isset($parts[0]) && $parts[0] instanceof DateTimeInterface) {
$this->setDateTimes($parts);
} else {
parent::setParts($parts);
}
-
}
/**
@@ -61,11 +58,9 @@ class DateTime extends Property {
* Instead of strings, you may also use DateTime here.
*
* @param string|array|DateTimeInterface $value
- *
- * @return void
*/
- function setValue($value) {
-
+ public function setValue($value)
+ {
if (is_array($value) && isset($value[0]) && $value[0] instanceof DateTimeInterface) {
$this->setDateTimes($value);
} elseif ($value instanceof DateTimeInterface) {
@@ -73,7 +68,6 @@ class DateTime extends Property {
} else {
parent::setValue($value);
}
-
}
/**
@@ -83,13 +77,10 @@ class DateTime extends Property {
* not yet done, but parameters are not included.
*
* @param string $val
- *
- * @return void
*/
- function setRawMimeDirValue($val) {
-
+ public function setRawMimeDirValue($val)
+ {
$this->setValue(explode($this->delimiter, $val));
-
}
/**
@@ -97,10 +88,9 @@ class DateTime extends Property {
*
* @return string
*/
- function getRawMimeDirValue() {
-
+ public function getRawMimeDirValue()
+ {
return implode($this->delimiter, $this->getParts());
-
}
/**
@@ -108,10 +98,9 @@ class DateTime extends Property {
*
* @return bool
*/
- function hasTime() {
-
- return strtoupper((string)$this['VALUE']) !== 'DATE';
-
+ public function hasTime()
+ {
+ return 'DATE' !== strtoupper((string) $this['VALUE']);
}
/**
@@ -119,15 +108,14 @@ class DateTime extends Property {
*
* Note that DATE is always floating.
*/
- function isFloating() {
-
+ public function isFloating()
+ {
return
!$this->hasTime() ||
(
!isset($this['TZID']) &&
- strpos($this->getValue(), 'Z') === false
+ false === strpos($this->getValue(), 'Z')
);
-
}
/**
@@ -143,15 +131,16 @@ class DateTime extends Property {
*
* @param DateTimeZone $timeZone
*
- * @return DateTimeImmutable
+ * @return \DateTimeImmutable
*/
- function getDateTime(DateTimeZone $timeZone = null) {
-
+ public function getDateTime(DateTimeZone $timeZone = null)
+ {
$dt = $this->getDateTimes($timeZone);
- if (!$dt) return;
+ if (!$dt) {
+ return;
+ }
return $dt[0];
-
}
/**
@@ -163,38 +152,35 @@ class DateTime extends Property {
*
* @param DateTimeZone $timeZone
*
- * @return DateTimeImmutable[]
+ * @return \DateTimeImmutable[]
* @return \DateTime[]
*/
- function getDateTimes(DateTimeZone $timeZone = null) {
-
+ public function getDateTimes(DateTimeZone $timeZone = null)
+ {
// Does the property have a TZID?
$tzid = $this['TZID'];
if ($tzid) {
- $timeZone = TimeZoneUtil::getTimeZone((string)$tzid, $this->root);
+ $timeZone = TimeZoneUtil::getTimeZone((string) $tzid, $this->root);
}
$dts = [];
foreach ($this->getParts() as $part) {
$dts[] = DateTimeParser::parse($part, $timeZone);
}
- return $dts;
+ return $dts;
}
/**
* Sets the property as a DateTime object.
*
* @param DateTimeInterface $dt
- * @param bool isFloating If set to true, timezones will be ignored.
- *
- * @return void
+ * @param bool isFloating If set to true, timezones will be ignored
*/
- function setDateTime(DateTimeInterface $dt, $isFloating = false) {
-
+ public function setDateTime(DateTimeInterface $dt, $isFloating = false)
+ {
$this->setDateTimes([$dt], $isFloating);
-
}
/**
@@ -204,21 +190,17 @@ class DateTime extends Property {
* the otehr values will be adjusted for that timezone
*
* @param DateTimeInterface[] $dt
- * @param bool isFloating If set to true, timezones will be ignored.
- *
- * @return void
+ * @param bool isFloating If set to true, timezones will be ignored
*/
- function setDateTimes(array $dt, $isFloating = false) {
-
+ public function setDateTimes(array $dt, $isFloating = false)
+ {
$values = [];
if ($this->hasTime()) {
-
$tz = null;
$isUtc = false;
foreach ($dt as $d) {
-
if ($isFloating) {
$values[] = $d->format('Ymd\\THis');
continue;
@@ -238,25 +220,18 @@ class DateTime extends Property {
} else {
$values[] = $d->format('Ymd\\THis');
}
-
}
if ($isUtc || $isFloating) {
$this->offsetUnset('TZID');
}
-
} else {
-
foreach ($dt as $d) {
-
$values[] = $d->format('Ymd');
-
}
$this->offsetUnset('TZID');
-
}
$this->value = $values;
-
}
/**
@@ -267,10 +242,9 @@ class DateTime extends Property {
*
* @return string
*/
- function getValueType() {
-
+ public function getValueType()
+ {
return $this->hasTime() ? 'DATE-TIME' : 'DATE';
-
}
/**
@@ -280,8 +254,8 @@ class DateTime extends Property {
*
* @return array
*/
- function getJsonValue() {
-
+ public function getJsonValue()
+ {
$dts = $this->getDateTimes();
$hasTime = $this->hasTime();
$isFloating = $this->isFloating();
@@ -290,18 +264,15 @@ class DateTime extends Property {
$isUtc = $isFloating ? false : in_array($tz->getName(), ['UTC', 'GMT', 'Z']);
return array_map(
- function(DateTimeInterface $dt) use ($hasTime, $isUtc) {
-
+ function (DateTimeInterface $dt) use ($hasTime, $isUtc) {
if ($hasTime) {
- return $dt->format('Y-m-d\\TH:i:s') . ($isUtc ? 'Z' : '');
+ return $dt->format('Y-m-d\\TH:i:s').($isUtc ? 'Z' : '');
} else {
return $dt->format('Y-m-d');
}
-
},
$dts
);
-
}
/**
@@ -310,26 +281,21 @@ class DateTime extends Property {
* The value must always be an array.
*
* @param array $value
- *
- * @return void
*/
- function setJsonValue(array $value) {
-
+ public function setJsonValue(array $value)
+ {
// dates and times in jCal have one difference to dates and times in
// iCalendar. In jCal date-parts are separated by dashes, and
// time-parts are separated by colons. It makes sense to just remove
// those.
$this->setValue(
array_map(
- function($item) {
-
+ function ($item) {
return strtr($item, [':' => '', '-' => '']);
-
},
$value
)
);
-
}
/**
@@ -337,20 +303,17 @@ class DateTime extends Property {
* VALUE from DATE-TIME to DATE or vice-versa.
*
* @param string $name
- * @param mixed $value
- *
- * @return void
+ * @param mixed $value
*/
- function offsetSet($name, $value) {
-
+ public function offsetSet($name, $value)
+ {
parent::offsetSet($name, $value);
- if (strtoupper($name) !== 'VALUE') {
+ if ('VALUE' !== strtoupper($name)) {
return;
}
// This will ensure that dates are correctly encoded.
$this->setDateTimes($this->getDateTimes());
-
}
/**
@@ -375,30 +338,30 @@ class DateTime extends Property {
*
* @return array
*/
- function validate($options = 0) {
-
+ public function validate($options = 0)
+ {
$messages = parent::validate($options);
$valueType = $this->getValueType();
$values = $this->getParts();
try {
foreach ($values as $value) {
switch ($valueType) {
- case 'DATE' :
+ case 'DATE':
DateTimeParser::parseDate($value);
break;
- case 'DATE-TIME' :
+ case 'DATE-TIME':
DateTimeParser::parseDateTime($value);
break;
}
}
} catch (InvalidDataException $e) {
$messages[] = [
- 'level' => 3,
- 'message' => 'The supplied value (' . $value . ') is not a correct ' . $valueType,
- 'node' => $this,
+ 'level' => 3,
+ 'message' => 'The supplied value ('.$value.') is not a correct '.$valueType,
+ 'node' => $this,
];
}
- return $messages;
+ return $messages;
}
}