VTimeZone.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * 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. * * ? - May appear, but not more than once.
  38. *
  39. * @var array
  40. */
  41. function getValidationRules() {
  42. return array(
  43. 'TZID' => 1,
  44. 'LAST-MODIFIED' => '?',
  45. 'TZURL' => '?',
  46. // At least 1 STANDARD or DAYLIGHT must appear, or more. But both
  47. // cannot appear in the same VTIMEZONE.
  48. //
  49. // The validator is not specific yet to pick this up, so these
  50. // rules are too loose.
  51. 'STANDARD' => '*',
  52. 'DAYLIGHT' => '*',
  53. );
  54. }
  55. }