TimeStamp.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace Sabre\VObject\Property\VCard;
  3. use
  4. Sabre\VObject\DateTimeParser,
  5. Sabre\VObject\Property\Text;
  6. /**
  7. * TimeStamp property
  8. *
  9. * This object encodes TIMESTAMP values.
  10. *
  11. * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved.
  12. * @author Evert Pot (http://evertpot.com/)
  13. * @license http://sabre.io/license/ Modified BSD License
  14. */
  15. class TimeStamp extends Text {
  16. /**
  17. * In case this is a multi-value property. This string will be used as a
  18. * delimiter.
  19. *
  20. * @var string|null
  21. */
  22. public $delimiter = null;
  23. /**
  24. * Returns the type of value.
  25. *
  26. * This corresponds to the VALUE= parameter. Every property also has a
  27. * 'default' valueType.
  28. *
  29. * @return string
  30. */
  31. public function getValueType() {
  32. return "TIMESTAMP";
  33. }
  34. /**
  35. * Returns the value, in the format it should be encoded for json.
  36. *
  37. * This method must always return an array.
  38. *
  39. * @return array
  40. */
  41. public function getJsonValue() {
  42. $parts = DateTimeParser::parseVCardDateTime($this->getValue());
  43. $dateStr =
  44. $parts['year'] . '-' .
  45. $parts['month'] . '-' .
  46. $parts['date'] . 'T' .
  47. $parts['hour'] . ':' .
  48. $parts['minute'] . ':' .
  49. $parts['second'];
  50. // Timezone
  51. if (!is_null($parts['timezone'])) {
  52. $dateStr.=$parts['timezone'];
  53. }
  54. return array($dateStr);
  55. }
  56. }