1<?php
2
3namespace Sabre\VObject\Component;
4
5use Sabre\VObject;
6
7/**
8 * The VTimeZone component
9 *
10 * This component adds functionality to a component, specific for VTIMEZONE
11 * components.
12 *
13 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
14 * @author Evert Pot (http://evertpot.com/)
15 * @license http://sabre.io/license/ Modified BSD License
16 */
17class VTimeZone extends VObject\Component {
18
19    /**
20     * Returns the PHP DateTimeZone for this VTIMEZONE component.
21     *
22     * If we can't accurately determine the timezone, this method will return
23     * UTC.
24     *
25     * @return \DateTimeZone
26     */
27    function getTimeZone() {
28
29        return VObject\TimeZoneUtil::getTimeZone((string)$this->TZID, $this->root);
30
31    }
32
33    /**
34     * A simple list of validation rules.
35     *
36     * This is simply a list of properties, and how many times they either
37     * must or must not appear.
38     *
39     * Possible values per property:
40     *   * 0 - Must not appear.
41     *   * 1 - Must appear exactly once.
42     *   * + - Must appear at least once.
43     *   * * - Can appear any number of times.
44     *   * ? - May appear, but not more than once.
45     *
46     * @var array
47     */
48    function getValidationRules() {
49
50        return array(
51            'TZID' => 1,
52
53            'LAST-MODIFIED' => '?',
54            'TZURL' => '?',
55
56            // At least 1 STANDARD or DAYLIGHT must appear, or more. But both
57            // cannot appear in the same VTIMEZONE.
58            //
59            // The validator is not specific yet to pick this up, so these
60            // rules are too loose.
61            'STANDARD' => '*',
62            'DAYLIGHT' => '*',
63        );
64
65    }
66
67}
68
69