Example #1
0
 /**
  * 引数のフィールドを, $amount だけ増加 (負の場合は減少) させます.
  * @param  string $field  対象のフィールド
  * @param  int    $amount 加算する量. マイナスの場合は過去方向に移動する.
  * @return Time           設定後の時間オブジェクト
  */
 public final function add($field, $amount)
 {
     $newFields = new ArrayMap($this->fields);
     $key = $this->getFieldIndex($field);
     $current = $this->fields->get($key);
     $newFields->put($key, $current + $amount);
     return $this->newInstance($newFields);
 }
Example #2
0
 /**
  * 指定された値の繰り下がり処理を行います.
  * この関数は Time::adjust() から呼び出されます.
  * 
  * @param Map $fields 調整対象のフィールド一覧
  * @ignore
  */
 public function moveDown(Map $fields)
 {
     $key = $this->key;
     $upperKey = $this->upperKey;
     $max = $this->max;
     $min = $this->min;
     $field = $fields->get($key);
     $upperField = $fields->get($upperKey);
     $range = $max - $min + 1;
     $amount = intval(($min - $field - 1) / $range) + 1;
     $fields->put($upperKey, $upperField - $amount);
     $fields->put($key, $max - ($min - $field - 1) % $range);
 }
Example #3
0
 /**
  * (non-PHPdoc)
  * @return Date
  * @see Time::newInstance
  * @ignore
  */
 protected function newInstance(Map $fields)
 {
     $year = $fields->get(self::$YEAR);
     $month = $fields->get(self::$MONTH);
     $date = $fields->get(self::$DATE);
     return new self($year, $month, $date);
 }
Example #4
0
 /**
  * この要素が持つすべての属性を配列で返します.
  * この要素の返り値を, そのまま {Element::setAttributes()}
  * の引数として使用することで属性のコピーをすることも出来ます.
  * 
  * @return array すべての属性の配列. キーが属性名, 値が属性値.
  * ただし値の省略された属性の場合は属性値が NULL となる.
  */
 public function getAttributes()
 {
     return $this->attributes->asArray();
 }
Example #5
0
 /**
  * (non-PHPdoc)
  * @see Time::newInstance()
  * @ignore
  */
 protected function newInstance(Map $fields)
 {
     $year = $fields->get(self::$YEAR);
     $month = $fields->get(self::$MONTH);
     $date = $fields->get(self::$DATE);
     $hour = $fields->get(self::$HOUR);
     $min = $fields->get(self::$MINUTE);
     $sec = $fields->get(self::$SECOND);
     return new self($year, $month, $date, $hour, $min, $sec);
 }