VTimeZone.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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) 2007-2014 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. * Returns the PHP DateTimeZone for this VTIMEZONE component.
  17. *
  18. * If we can't accurately determine the timezone, this method will return
  19. * UTC.
  20. *
  21. * @return \DateTimeZone
  22. */
  23. function getTimeZone() {
  24. return VObject\TimeZoneUtil::getTimeZone((string)$this->TZID, $this->root);
  25. }
  26. /**
  27. * A simple list of validation rules.
  28. *
  29. * This is simply a list of properties, and how many times they either
  30. * must or must not appear.
  31. *
  32. * Possible values per property:
  33. * * 0 - Must not appear.
  34. * * 1 - Must appear exactly once.
  35. * * + - Must appear at least once.
  36. * * * - Can appear any number of times.
  37. *
  38. * @var array
  39. */
  40. function getValidationRules() {
  41. return array(
  42. 'TZID' => 1,
  43. 'LAST-MODIFICATION' => '?',
  44. 'TZURL' => '?',
  45. // At least 1 STANDARD or DAYLIGHT must appear, or more. But both
  46. // cannot appear in the same VTIMEZONE.
  47. //
  48. // The validator is not specific yet to pick this up, so these
  49. // rules are too loose.
  50. 'STANDARD' => '*',
  51. 'DAYLIGHT' => '*',
  52. );
  53. }
  54. }