annotate vendor/sabre/vobject/lib/Property/VCard/TimeStamp.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1 <?php
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject\Property\VCard;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 use
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6 Sabre\VObject\DateTimeParser,
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7 Sabre\VObject\Property\Text;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10 * TimeStamp property
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 * This object encodes TIMESTAMP values.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/).
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15 * @author Evert Pot (http://evertpot.com/)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16 * @license http://sabre.io/license/ Modified BSD License
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18 class TimeStamp extends Text {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21 * In case this is a multi-value property. This string will be used as a
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22 * delimiter.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24 * @var string|null
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26 public $delimiter = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
29 * Returns the type of value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
30 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
31 * This corresponds to the VALUE= parameter. Every property also has a
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
32 * 'default' valueType.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34 * @return string
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36 public function getValueType() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38 return "TIMESTAMP";
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43 * Returns the value, in the format it should be encoded for json.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45 * This method must always return an array.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47 * @return array
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 public function getJsonValue() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51 $parts = DateTimeParser::parseVCardDateTime($this->getValue());
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53 $dateStr =
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54 $parts['year'] . '-' .
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55 $parts['month'] . '-' .
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56 $parts['date'] . 'T' .
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 $parts['hour'] . ':' .
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58 $parts['minute'] . ':' .
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 $parts['second'];
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
60
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
61 // Timezone
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
62 if (!is_null($parts['timezone'])) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63 $dateStr.=$parts['timezone'];
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66 return array($dateStr);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69 }