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