VTimeZone.php 1.6 KB

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