/src/Zend/Media/Id3/Frame/Time.php

http://php-reader.googlecode.com/ · PHP · 105 lines · 36 code · 7 blank · 62 comment · 0 complexity · c6cb48245e90da03872557a17245a892 MD5 · raw file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Media
  17. * @subpackage ID3
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: Time.php 177 2010-03-09 13:13:34Z svollbehr $
  21. * @deprecated ID3v2.3.0
  22. */
  23. /**#@+ @ignore */
  24. require_once 'Zend/Media/Id3/DateFrame.php';
  25. /**#@-*/
  26. /**
  27. * The <i>Time</i> frame contains the time for the recording in the HHMM format.
  28. *
  29. * @category Zend
  30. * @package Zend_Media
  31. * @subpackage ID3
  32. * @author Sven Vollbehr <sven@vollbehr.eu>
  33. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. * @version $Id: Time.php 177 2010-03-09 13:13:34Z svollbehr $
  36. * @deprecated ID3v2.3.0
  37. */
  38. final class Zend_Media_Id3_Frame_Time extends Zend_Media_Id3_DateFrame
  39. {
  40. private $_hours;
  41. private $_minutes;
  42. /**
  43. * Constructs the class with given parameters and parses object related
  44. * data.
  45. *
  46. * @param Zend_Io_Reader $reader The reader object.
  47. * @param Array $options The options array.
  48. */
  49. public function __construct($reader = null, &$options = array())
  50. {
  51. parent::__construct($reader, $options, 'HHmm');
  52. $this->_hours = substr($this->getText(), 0, 2);
  53. $this->_minutes = substr($this->getText(), 2, 2);
  54. }
  55. /**
  56. * Returns the hour.
  57. *
  58. * @return integer
  59. */
  60. public function getHour()
  61. {
  62. return intval($this->_hours);
  63. }
  64. /**
  65. * Sets the hour.
  66. *
  67. * @param integer $hours The hours.
  68. */
  69. public function setHour($hours)
  70. {
  71. $this->setText
  72. (($this->_hours = str_pad(strval($hours), 2, "0", STR_PAD_LEFT)) .
  73. ($this->_minutes ? $this->_minutes : '00'),
  74. Zend_Media_Id3_Encoding::ISO88591);
  75. }
  76. /**
  77. * Returns the minutes.
  78. *
  79. * @return integer
  80. */
  81. public function getMinute()
  82. {
  83. return intval($this->_minutes);
  84. }
  85. /**
  86. * Sets the minutes.
  87. *
  88. * @param integer $minutes The minutes.
  89. */
  90. public function setMinute($minutes)
  91. {
  92. $this->setText
  93. (($this->_hours ? $this->_hours : '00') .
  94. ($this->_minutes =
  95. str_pad(strval($minutes), 2, "0", STR_PAD_LEFT)),
  96. Zend_Media_Id3_Encoding::ISO88591);
  97. }
  98. }