示例#1
0
文件: ascii.php 项目: ni-c/pel
 function testReturnValues()
 {
     $pattern = new PatternExpectation('/Missing argument 1 for ' . 'PelEntryAscii::__construct()/');
     $this->expectError($pattern);
     $this->expectError('Undefined variable: tag');
     $entry = new PelEntryAscii();
     $entry = new PelEntryAscii(42);
     $entry = new PelEntryAscii(42, 'foo bar baz');
     $this->assertEqual($entry->getComponents(), 12);
     $this->assertEqual($entry->getValue(), 'foo bar baz');
 }
 /**
  * Update the copyright information.
  *
  * @param string the photographer copyright.  Use the empty string
  * if there is no photographer copyright.
  *
  * @param string the editor copyright.  Use the empty string if
  * there is no editor copyright.
  */
 function setValue($photographer = '', $editor = '')
 {
     $this->photographer = $photographer;
     $this->editor = $editor;
     if ($photographer == '' && $editor != '') {
         $photographer = ' ';
     }
     if ($editor == '') {
         parent::setValue($photographer);
     } else {
         parent::setValue($photographer . chr(0x0) . $editor);
     }
 }
示例#3
0
 /**
  * Update the timestamp held by this entry.
  *
  * @param
  *            int the timestamp held by this entry in the correct form
  *            as indicated by the third argument. For {@link UNIX_TIMESTAMP}
  *            this is an integer counting the number of seconds since January
  *            1st 1970, for {@link EXIF_STRING} this is a string of the form
  *            'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a
  *            floating point number where the integer part denotes the day
  *            count and the fractional part denotes the time of day (0.25 means
  *            6:00, 0.75 means 18:00).
  *
  * @param
  *            int the type of the timestamp. This must be one of
  *            {@link UNIX_TIMESTAMP}, {@link EXIF_STRING}, or
  *            {@link JULIAN_DAY_COUNT}.
  */
 public function setValue($timestamp, $type = self::UNIX_TIMESTAMP)
 {
     // if (empty($timestamp))
     // debug_print_backtrace();
     switch ($type) {
         case self::UNIX_TIMESTAMP:
             $this->day_count = $this->convertUnixToJd($timestamp);
             $this->seconds = $timestamp % 86400;
             break;
         case self::EXIF_STRING:
             /* Clean the timestamp: some timestamps are broken other
              * separators than ':' and ' '. */
             $d = preg_split('/[^0-9]+/', $timestamp);
             for ($i = 0; $i < 6; $i++) {
                 if (empty($d[$i])) {
                     $d[$i] = 0;
                 }
             }
             $this->day_count = $this->convertGregorianToJd($d[0], $d[1], $d[2]);
             $this->seconds = $d[3] * 3600 + $d[4] * 60 + $d[5];
             break;
         case self::JULIAN_DAY_COUNT:
             $this->day_count = (int) floor($timestamp);
             $this->seconds = (int) (86400 * ($timestamp - floor($timestamp)));
             break;
         default:
             throw new PelInvalidArgumentException('Expected UNIX_TIMESTAMP (%d), ' . 'EXIF_STRING (%d), or ' . 'JULIAN_DAY_COUNT (%d) for $type, ' . 'got %d.', self::UNIX_TIMESTAMP, self::EXIF_STRING, self::JULIAN_DAY_COUNT, $type);
     }
     /*
      * Now finally update the string which will be used when this is
      * turned into bytes.
      */
     parent::setValue($this->getValue(self::EXIF_STRING));
 }