41 return 'DATE-AND-OR-TIME';
56 if (
count($parts) > 1) {
57 throw new \InvalidArgumentException(
'Only one value allowed');
62 parent::setParts($parts);
97 $tz = $dt->getTimeZone();
98 $isUtc = in_array(
$tz->getName(), [
'UTC',
'GMT',
'Z']);
101 $value = $dt->format(
'Ymd\\THis\\Z');
104 $value = $dt->format(
'Ymd\\THisO');
131 $tzFormat = $now->getTimezone()->getOffset($now) === 0 ?
'\\Z' :
'O';
139 foreach ($dateParts as $k => $v) {
141 $dateParts[$k] = $nowParts[$k];
144 return new DateTimeImmutable(
"$dateParts[year]-$dateParts[month]-$dateParts[date] $dateParts[hour]:$dateParts[minute]:$dateParts[second] $dateParts[timezone]");
162 if (!is_null($parts[
'year'])) {
164 $dateStr .= $parts[
'year'];
166 if (!is_null($parts[
'month'])) {
174 if (!is_null($parts[
'month']) || !is_null($parts[
'date'])) {
182 if (!is_null($parts[
'month'])) {
184 $dateStr .= $parts[
'month'];
186 if (isset($parts[
'date'])) {
191 } elseif (isset($parts[
'date'])) {
198 if (!is_null($parts[
'date'])) {
199 $dateStr .= $parts[
'date'];
204 if (is_null($parts[
'hour']) && is_null($parts[
'minute']) && is_null($parts[
'second'])) {
211 if (!is_null($parts[
'hour'])) {
213 $dateStr .= $parts[
'hour'];
215 if (!is_null($parts[
'minute'])) {
226 if (!is_null($parts[
'minute'])) {
228 $dateStr .= $parts[
'minute'];
230 if (!is_null($parts[
'second'])) {
234 } elseif (isset($parts[
'second'])) {
240 if (!is_null($parts[
'second'])) {
241 $dateStr .= $parts[
'second'];
245 if (!is_null($parts[
'timezone'])) {
246 $dateStr .= $parts[
'timezone'];
268 $d =
function($part) use ($parts) {
269 return !is_null($parts[$part]);
273 $r =
function($part) use ($parts) {
274 return $parts[$part];
283 if ((
$d(
'year') ||
$d(
'month') ||
$d(
'date'))
284 && (!
$d(
'hour') && !
$d(
'minute') && !
$d(
'second') && !
$d(
'timezone'))) {
286 if (
$d(
'year') &&
$d(
'month') &&
$d(
'date')) {
288 } elseif (
$d(
'year') &&
$d(
'month') && !
$d(
'date')) {
290 } elseif (!
$d(
'year') &&
$d(
'month')) {
292 } elseif (!
$d(
'year') && !
$d(
'month') &&
$d(
'date')) {
301 } elseif ((!
$d(
'year') && !
$d(
'month') && !
$d(
'date'))
302 && (
$d(
'hour') ||
$d(
'minute') ||
$d(
'second'))) {
306 } elseif (
$d(
'minute')) {
308 } elseif (
$d(
'second')) {
319 } elseif (
$d(
'date') &&
$d(
'hour')) {
321 if (
$d(
'year') &&
$d(
'month') &&
$d(
'date')) {
323 } elseif (!
$d(
'year') &&
$d(
'month') &&
$d(
'date')) {
325 } elseif (!
$d(
'year') && !
$d(
'month') &&
$d(
'date')) {
329 $value .=
'T' .
$r(
'hour') .
$r(
'minute') .
$r(
'second') .
334 $writer->writeElement($valueType,
$value);
361 return implode($this->delimiter, $this->
getParts());
397 'message' =>
'The supplied value (' .
$value .
') is not a correct DATE-AND-OR-TIME property',
setValue($value)
Updates the current value.
getValueType()
Returns the type of value.
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
validate($options=0)
Validates the node for correctness.
setRawMimeDirValue($val)
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
static parseVCardDateAndOrTime($date)
This method parses a vCard date and or time value.
setParts(array $parts)
Sets a multi-valued property.
getJsonValue()
Returns the value, in the format it should be encoded for json.
getParts()
Returns a multi-valued property.
getDateTime()
Returns a date-time value.
setDateTime(DateTimeInterface $dt)
Sets the property as a DateTime object.
count()
Returns the number of elements.
getValue()
Returns the current value.
getRawMimeDirValue()
Returns a raw mime-dir representation of the value.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
static parseVCardDateTime($date)
This method parses a vCard date and or time value.
This exception is thrown whenever an invalid value is found anywhere in a iCalendar or vCard object...
xmlSerializeValue(Xml\Writer $writer)
This method serializes only the value of a property.