当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale_Format::getFloat方法代码示例

本文整理汇总了PHP中Zend_Locale_Format::getFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale_Format::getFloat方法的具体用法?PHP Zend_Locale_Format::getFloat怎么用?PHP Zend_Locale_Format::getFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Locale_Format的用法示例。


在下文中一共展示了Zend_Locale_Format::getFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveInformation

 /**
  * 
  * @return int|bool
  */
 public function saveInformation()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         //if ( !$this->_validateClass() )
         //return false;
         $date = new Zend_Date();
         $this->_data['start_date'] = $date->set($this->_data['start_date'])->toString('yyyy-MM-dd');
         $this->_data['schedule_finish_date'] = $date->set($this->_data['schedule_finish_date'])->toString('yyyy-MM-dd');
         if (!empty($this->_data['real_finish_date'])) {
             $this->_data['real_finish_date'] = $date->set($this->_data['real_finish_date'])->toString('yyyy-MM-dd');
         }
         if (!empty($this->_data['student_payment'])) {
             $this->_data['student_payment'] = Zend_Locale_Format::getFloat($this->_data['student_payment'], array('locale' => 'en_US'));
         }
         if (!empty($this->_data['subsidy'])) {
             $this->_data['subsidy'] = Zend_Locale_Format::getFloat($this->_data['subsidy'], array('locale' => 'en_US'));
         }
         if (empty($this->_data['id_fefpstudentclass'])) {
             $history = 'REJISTRU  Klasse Formasaun - La Iha Proposta: %s';
             $this->_data['active'] = 1;
             $filters = array('fk_id_fefpeduinstitution' => $this->_data['fk_id_fefpeduinstitution'], 'fk_id_perscholarity' => $this->_data['fk_id_perscholarity'], 'fk_id_dec' => $this->_data['fk_id_dec'], 'start_date' => $this->_data['start_date'], 'schedule_finish_date' => $this->_data['schedule_finish_date'], 'active' => 1);
             $classIdentic = $this->_dbTable->fetchAll($filters, array('id_fefpstudentclass DESC'))->current();
             if (!empty($classIdentic)) {
                 $start = 1;
                 if (preg_match('/([0-9]+)$/i', $classIdentic->class_name, $match)) {
                     $start = (int) $match[1] + 1;
                 }
                 $this->_data['class_name'] .= ' - ' . $start;
             }
         } else {
             unset($this->_data['fk_id_fefpeduinstitution'], $this->_data['fk_id_dec']);
             if (empty($this->_data['fk_id_perscholarity'])) {
                 unset($this->_data['fk_id_perscholarity']);
             }
             $history = 'ATUALIZA  Klasse Formasaun - La Iha Proposta: %s';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:53,代码来源:StudentClass.php

示例2: set

 /**
  * Return a value for set, using some validations from the table data.
  *
  * @param string $type  Type of field.
  * @param mixed  $value Value to transform.
  *
  * @return mixed Sanitized value.
  */
 public static function set($type, $value)
 {
     switch ($type) {
         case 'int':
             $value = Cleaner::sanitize('integer', $value, 0);
             break;
         case 'float':
             $value = Cleaner::sanitize('float', $value, 0);
             if ($value !== false) {
                 $value = Zend_Locale_Format::getFloat($value, array('precision' => 2));
             } else {
                 $value = 0;
             }
             break;
         case 'date':
             $value = Cleaner::sanitize('date', $value);
             break;
         case 'time':
             $value = Cleaner::sanitize('time', $value);
             $value = date("H:i:s", Phprojekt_Converter_Time::userToUtc($value));
             break;
         case 'datetime':
         case 'timestamp':
             $value = Cleaner::sanitize('timestamp', $value);
             $value = date("Y-m-d H:i:s", Phprojekt_Converter_Time::userToUtc($value));
             break;
         case 'text':
             if (is_array($value)) {
                 // if given value for a text field is an array, it's from a MultiSelect field
                 $value = implode(',', $value);
             }
             // Run html sanitize only if the text contain some html code
             if (preg_match("/([\\<])([^\\>]{1,})*([\\>])/i", $value)) {
                 $value = Cleaner::sanitize('html', $value);
             } else {
                 $value = Cleaner::sanitize('string', $value);
             }
             break;
         default:
             $value = Cleaner::sanitize('string', $value);
             break;
     }
     return $value;
 }
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:52,代码来源:Value.php

示例3: saveInformation

 /**
  * 
  * @return int|bool
  */
 public function saveInformation()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $date = new Zend_Date();
         if (!empty($this->_data['date_start'])) {
             $this->_data['date_start'] = $date->set($this->_data['date_start'])->toString('yyyy-MM-dd');
         }
         if (!empty($this->_data['date_finish'])) {
             $this->_data['date_finish'] = $date->set($this->_data['date_finish'])->toString('yyyy-MM-dd');
         }
         if (!empty($this->_data['salary'])) {
             $this->_data['salary'] = Zend_Locale_Format::getFloat($this->_data['salary'], array('locale' => 'en_US'));
         }
         if (empty($this->_data['id_jobtraining'])) {
             $history = 'REJISTRU JOB TRAINING: %s';
             $this->_data['active'] = 1;
         } else {
             unset($this->_data['fk_id_dec']);
             $history = 'ATUALIZA JOB TRAINING: %s';
             $where = array('fk_id_jobtraining = ?' => $this->_data['id_jobtraining'], 'status = ?' => 0);
             $dbTrainee = App_Model_DbTable_Factory::get('JOBTraining_Trainee');
             $trainees = $dbTrainee->fetchAll($where);
             foreach ($trainees as $trainee) {
                 $trainee->date_start = $this->_data['date_start'];
                 $trainee->date_finish = $this->_data['date_finish'];
                 $trainee->duration = $this->_data['duration'];
                 $trainee->save();
             }
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:46,代码来源:JobTraining.php

示例4: saveInformation

 /**
  * 
  * @return int|bool
  */
 public function saveInformation()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         if (!$this->_validateJobVacancy()) {
             return false;
         }
         $date = new Zend_Date();
         $this->_data['registration_date'] = $date->set($this->_data['registration_date'])->toString('yyyy-MM-dd');
         $this->_data['open_date'] = $date->set($this->_data['open_date'])->toString('yyyy-MM-dd');
         $this->_data['close_date'] = $date->set($this->_data['close_date'])->toString('yyyy-MM-dd');
         if (!empty($this->_data['start_job_date'])) {
             $this->_data['start_job_date'] = $date->set($this->_data['start_job_date'])->toString('yyyy-MM-dd');
         }
         if (!empty($this->_data['finish_job_date'])) {
             $this->_data['finish_job_date'] = $date->set($this->_data['finish_job_date'])->toString('yyyy-MM-dd');
         }
         $this->_data['start_salary'] = Zend_Locale_Format::getFloat(empty($this->_data['start_salary']) ? 0 : $this->_data['start_salary'], array('locale' => 'en_US'));
         $this->_data['finish_salary'] = Zend_Locale_Format::getFloat(empty($this->_data['finish_salary']) ? 0 : $this->_data['finish_salary'], array('locale' => 'en_US'));
         $this->_data['additional_salary'] = Zend_Locale_Format::getFloat(empty($this->_data['additional_salary']) ? 0 : $this->_data['additional_salary'], array('locale' => 'en_US'));
         $this->_data['post'] = '-';
         if (empty($this->_data['id_jobvacancy'])) {
             $history = 'REJISTRU VAGA EMPREGU NUMERU: %s - DADOS PRICIPAIS VAGA DE EMPREGO REGISTRADO';
             $this->_data['active'] = 1;
         } else {
             $history = 'ATUALIZADO VAGA EMPREGU NUMERU: %s - DADOS PRICIPAIS VAGA DE EMPREGO ATUALIZADO';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:43,代码来源:JobVacancy.php

示例5: testgetFloat

    /**
     * test getFloat
     * expected exception
     */
    public function testgetFloat()
    {
        try {
            $value = Zend_Locale_Format::getFloat('nocontent');
            $this->fail("exception expected");
        } catch (Zend_Locale_Exception $e) {
            // success
        }

        $this->assertEquals(       0,         Zend_Locale_Format::getFloat(       0        ));
        $this->assertEquals(-1234567,         Zend_Locale_Format::getFloat(-1234567        ));
        $this->assertEquals( 1234567,         Zend_Locale_Format::getFloat( 1234567        ));
        $this->assertEquals(       0.1234567, Zend_Locale_Format::getFloat(       0.1234567));
        $this->assertEquals(-1234567.12345,   Zend_Locale_Format::getFloat(-1234567.12345  ));
        $this->assertEquals( 1234567.12345,   Zend_Locale_Format::getFloat( 1234567.12345  ));

        $options = array('locale' => 'de');
        $this->assertEquals(       0,         Zend_Locale_Format::getFloat(         '0',         $options));
        $this->assertEquals(-1234567,         Zend_Locale_Format::getFloat(  '-1234567',         $options));
        $this->assertEquals( 1234567,         Zend_Locale_Format::getFloat(   '1234567',         $options));
        $this->assertEquals(       0.1234567, Zend_Locale_Format::getFloat(         '0,1234567', $options));
        $this->assertEquals(-1234567.12345,   Zend_Locale_Format::getFloat('-1.234.567,12345',   $options));
        $this->assertEquals( 1234567.12345,   Zend_Locale_Format::getFloat( '1.234.567,12345',   $options));

        $options = array('locale' => 'de_AT');
        $this->assertEquals(       0,         Zend_Locale_Format::getFloat(         '0',         $options));
        $this->assertEquals(-1234567,         Zend_Locale_Format::getFloat(  '-1234567',         $options));
        $this->assertEquals( 1234567,         Zend_Locale_Format::getFloat( '1.234.567',         $options));
        $this->assertEquals(       0.1234567, Zend_Locale_Format::getFloat(         '0,1234567', $options));
        $this->assertEquals(-1234567.12345,   Zend_Locale_Format::getFloat('-1.234.567,12345',   $options));
        $this->assertEquals( 1234567.12345,   Zend_Locale_Format::getFloat( '1.234.567,12345',   $options));

        $options = array('precision' => 2, 'locale' => 'de_AT');
        $this->assertEquals(       0,    Zend_Locale_Format::getFloat(         '0',         $options));
        $this->assertEquals(-1234567,    Zend_Locale_Format::getFloat(  '-1234567',         $options));
        $this->assertEquals( 1234567,    Zend_Locale_Format::getFloat( '1.234.567',         $options));
        $this->assertEquals(       0.12, Zend_Locale_Format::getFloat(         '0,1234567', $options));
        $this->assertEquals(-1234567.12, Zend_Locale_Format::getFloat('-1.234.567,12345',   $options));
        $this->assertEquals( 1234567.12, Zend_Locale_Format::getFloat( '1.234.567,12345',   $options));

        $options = array('precision' => 7, 'locale' => 'de_AT');
        $this->assertEquals('1234567.12345', Zend_Locale_Format::getFloat('1.234.567,12345', $options));
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:47,代码来源:FormatTest.php

示例6: setFromArray

 /**
  * Nadpisana metoda update'u wiersza tabeli z uwzględnieniem mailera
  * @param array $data
  * @return type
  */
 public function setFromArray(array $data)
 {
     $headerMappings = $this->getHeaderMappings();
     if (isset($data['send_mail'])) {
         $this->send_mail = $data['send_mail'];
         unset($data['send_mail']);
     }
     foreach ($data as $key => $value) {
         if (isset($headerMappings[$key]['format'])) {
             switch ($headerMappings[$key]['format']) {
                 case 'currency':
                     $data[$key] = Zend_Locale_Format::getFloat($value);
                     break;
             }
         }
         if ($value == null) {
             $data[$key] = null;
         }
     }
     parent::setFromArray($data);
     if (isset($data['id_state']) && $this->send_mail) {
         $mailer = new Logic_Mailer(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'), $translate);
         $userModel = new User();
         //receiver data
         if (get_called_class() === 'Row_DelegationSettlement') {
             if ($data['id_state'] == Logic_Settlements::STATE_APPROVED_2) {
                 $receiverRow = $userModel->findOne($this->settlement_by);
             } elseif (!is_null($this->created_by)) {
                 $receiverRow = $userModel->findOne($this->created_by);
             } else {
                 $receiverRow = $userModel->findOne($this->settlement_by);
             }
             $delegation = $this->findParentRow('Delegation');
         } else {
             if (get_called_class() === 'Row_Delegation') {
                 if ($data['id_state'] == Logic_Settlements::STATE_APPROVED) {
                     $receiverRow = $userModel->findOne($this->acceptance_by);
                 } else {
                     $receiverRow = $userModel->findOne($this->created_by);
                 }
                 $params['deleg_no'] = $this->deleg_no;
             } else {
                 return $this;
             }
         }
         $params['email'] = $receiverRow->email;
         //diee($params['email']);
         //sender data
         $senderRow = Zend_Auth::getInstance()->getIdentity();
         $params['user_full_name'] = $senderRow->first_name . ' ' . $senderRow->surname;
         $params['departament'] = $senderRow->department;
         $params['KOD_MPK'] = $senderRow->jednostka['symbol'];
         //email body data
         $params['id'] = $this->id;
         if (isset($data['deleg_no'])) {
             $params['deleg_no'] = $data['deleg_no'];
         } elseif (isset($this->deleg_no)) {
             $params['deleg_no'] = $this->deleg_no;
         } elseif (isset($delegation->deleg_no)) {
             $params['deleg_no'] = $delegation->deleg_no;
         }
         try {
             switch ($data['id_state']) {
                 case Logic_Settlements::STATE_ACCEPTED:
                     $mailer->acceptedByDelegation($params);
                     break;
                 case Logic_Settlements::STATE_APPROVED:
                     $mailer->acceptDelegation($params);
                     break;
                 case Logic_Settlements::STATE_APPROVED_2:
                     $mailer->settleDelegation($params);
                     break;
                 case Logic_Settlements::STATE_CORRECTION:
                     $mailer->correctDelegation($params);
                     break;
                 case Logic_Settlements::STATE_SETTLED:
                     $mailer->settledDelegation($params);
                     break;
                 case Logic_Settlements::STATE_APPROVED_ACCOUNTING:
                     $mailer->approvedDelegation($params);
                     break;
                     //                case Logic_Settlements::STATE_SETTLED
             }
         } catch (Exception $e) {
             $messenger = new Base_View_Helper_Messenger();
             $messenger->error($e->getMessage());
         }
     }
     return $this;
 }
开发者ID:knatorski,项目名称:SMS,代码行数:95,代码来源:Row.php

示例7: testShortNotation

 public function testShortNotation()
 {
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(0.12345));
     $options = array('locale' => 'de');
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(',12345', $options));
     $this->assertEquals('0,75', Zend_Locale_Format::toNumber(0.75, array('locale' => 'de_DE', 'precision' => 2)));
     $this->assertTrue(Zend_Locale_Format::isNumber(',12345', array('locale' => 'de_AT')));
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(0.12345));
     $options = array('locale' => 'de');
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0,12345', Zend_Locale_Format::toFloat(0.12345, $options));
     $options = array('locale' => 'ar_QA');
     $this->assertEquals('0,12345', Zend_Locale_Format::toFloat(0.12345, $options));
     $this->assertTrue(Zend_Locale_Format::isFloat(',12345', array('locale' => 'de_AT')));
     $this->assertEquals(0, Zend_Locale_Format::getInteger(0.1234567));
     $options = array('locale' => 'de');
     $this->assertEquals(0, Zend_Locale_Format::getInteger(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0, Zend_Locale_Format::getInteger(',12345', $options));
     $this->assertEquals('0', Zend_Locale_Format::toInteger(0.123, array('locale' => 'de')));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0', Zend_Locale_Format::toInteger(0.12345, $options));
     $this->assertFalse(Zend_Locale_Format::isInteger(',12345', array('locale' => 'de_AT')));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0,567', Zend_Locale_Format::toNumber(0.5669999999999999, $options));
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:31,代码来源:FormatTest.php

示例8: testRegionSeperatedPositiveFloatPrecAdd

 /**
  * test positive float seperation language locale precision
  * expected integer
  */
 public function testRegionSeperatedPositiveFloatPrecAdd()
 {
     $value = Zend_Locale_Format::getFloat('1.234.567,12345', 7, 'de_AT');
     $this->assertEquals($value, '1234567.12345', "value 1234567.12345 expected");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:FormatTest.php

示例9: _normalize

 /**
  * Reads a localized value, normalizes and returns it.
  * Returns an empty string if no value is passed.
  * @param mixed $value
  * @param string $type (boolean|date|time|integer|float|decimal|currency)
  * @return mixed
  */
 private function _normalize($value, $type, $num_of_decimals)
 {
     if (strlen($value) == 0) {
         return '';
     }
     switch ($type) {
         case 'boolean':
             $yes_no = Zend_Locale_Data::getContent($this->_locale_engine, 'questionstrings');
             $yes_regexp = '/^(' . str_replace(':', '|', $yes_no['yes']) . ')$/i';
             if (preg_match($yes_regexp, $value)) {
                 return 1;
             }
             return 0;
         case 'date':
             $date = Zend_Locale_Format::getDate($value, array('locale' => $this->_locale_engine, 'fix_date' => true));
             $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
             $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
             return "{$date['year']}-{$date['month']}-{$date['day']}";
         case 'time':
             $date_format = Zend_Locale_Format::getTimeFormat($this->_locale_engine);
             $date = Zend_Locale_Format::getDate($value, array('date_format' => $date_format, 'locale' => $this->_locale_engine));
             if (!isset($date['hour'])) {
                 $date['hour'] = '00';
             }
             if (!isset($date['minute'])) {
                 $date['minute'] = '00';
             }
             if (!isset($date['second'])) {
                 $date['second'] = '00';
             }
             return "{$date['hour']}:{$date['minute']}:{$date['second']}";
         case 'datetime':
             $date = Zend_Locale_Format::getDateTime($value, array('locale' => $this->_locale_engine, 'fix_date' => true));
             $date['month'] = str_pad($date['month'], 2, 0, STR_PAD_LEFT);
             $date['day'] = str_pad($date['day'], 2, 0, STR_PAD_LEFT);
             $date['hour'] = str_pad($date['hour'], 2, 0, STR_PAD_LEFT);
             $date['minute'] = str_pad($date['minute'], 2, 0, STR_PAD_LEFT);
             $date['second'] = str_pad($date['second'], 2, 0, STR_PAD_LEFT);
             return "{$date['year']}-{$date['month']}-{$date['day']} {$date['hour']}:{$date['minute']}:{$date['second']}";
             break;
         case 'integer':
             return Zend_Locale_Format::getInteger($value, array('locale' => $this->_locale_engine));
         case 'float':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 3;
             }
             return Zend_Locale_Format::getFloat($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine));
         case 'decimal':
             if ($num_of_decimals === null) {
                 $num_of_decimals = 2;
             }
             return Zend_Locale_Format::getFloat($value, array('precision' => $num_of_decimals, 'locale' => $this->_locale_engine));
     }
     return $value;
 }
开发者ID:eliudiaz,项目名称:p4a,代码行数:62,代码来源:p4a_i18n.php

示例10: testgetFloat

 /**
  * test getFloat
  * expected exception
  */
 public function testgetFloat()
 {
     try {
         $value = Zend_Locale_Format::getFloat('nocontent');
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     $this->assertEquals(Zend_Locale_Format::getFloat(0), 0, "value 0 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat(-1234567), -1234567, "value -1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat(1234567), 1234567, "value 1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat(0.1234567), 0.1234567, "value 0.1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat(-1234567.12345), -1234567.12345, "value -1234567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat(1234567.12345), 1234567.12345, "value 1234567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('0', 'de'), 0, "value 0 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('-1234567', 'de'), -1234567, "value -1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1234567', 'de'), 1234567, "value 1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('0,1234567', 'de'), 0.1234567, "value 0.1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('-1.234.567,12345', 'de'), -1234567.12345, "value -1234567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1.234.567,12345', 'de'), 1234567.12345, "value 1234567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('0', 'de_AT'), 0, "value 0 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('-1234567', 'de_AT'), -1234567, "value -1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1.234.567', 'de_AT'), 1234567, "value 1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('0,1234567', 'de_AT'), 0.1234567, "value 0.1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('-1.234.567,12345', 'de_AT'), -1234567.12345, "value -1234567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1.234.567,12345', 'de_AT'), 1234567.12345, "value 1234567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('0', 2, 'de_AT'), 0, "value 0 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('-1234567', 2, 'de_AT'), -1234567, "value -1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1.234.567', 2, 'de_AT'), 1234567, "value 1234567 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('0,1234567', 2, 'de_AT'), 0.12, "value 0.12 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('-1.234.567,12345', 2, 'de_AT'), -1234567.12, "value -1234567.12 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1.234.567,12345', 2, 'de_AT'), 1234567.12, "value 1234567.12 expected");
     $this->assertEquals(Zend_Locale_Format::getFloat('1.234.567,12345', 7, 'de_AT'), '1234567.12345', "value 1234567.12345 expected");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:38,代码来源:FormatTest.php

示例11: fileSize

 /**
  * Formats filesize with specified precision
  *
  * @param integer $fileSize Filesize in bytes
  * @param integer $precision Precision
  * @param string $norm Which norm use - 'traditional' (1 KB = 2^10 B), 'si' (1 KB = 10^3 B), 'iec' (1 KiB = 2^10 B)
  * @param string $type Defined export type
  */
 public function fileSize($fileSize, $precision = 0, $norm = 'traditional', $type = null)
 {
     try {
         require_once 'Zend/Registry.php';
         $locale = Zend_Registry::get('Zend_Locale');
         require_once 'Zend/Locale.php';
         if (!$locale instanceof Zend_Locale) {
             require_once 'Zend/Exception.php';
             throw new Zend_Exception('Locale is not set correctly.');
         }
         $isLocaleSet = true;
     } catch (Zend_Exception $e) {
         $isLocaleSet = false;
         $locale = null;
     }
     if ($isLocaleSet) {
         /**
          * @see Zend_Locale_Math
          */
         require_once 'Zend/Locale/Format.php';
         //get localised input value
         $fileSize = Zend_Locale_Format::getFloat($fileSize, array('locale' => $locale));
     } else {
         $fileSize = floatval($fileSize);
     }
     $m = new Zend_Measure_Binary($fileSize, null, $locale);
     $m->setType('BYTE');
     if (null === $norm) {
         $norm = 'traditional';
     }
     if (isset($type)) {
         $m->setType($type);
     } elseif ($norm === 'traditional') {
         if ($fileSize >= $this->_getUnitSize('TERABYTE')) {
             $m->setType(Zend_Measure_Binary::TERABYTE);
         } else {
             if ($fileSize >= $this->_getUnitSize('GIGABYTE')) {
                 $m->setType(Zend_Measure_Binary::GIGABYTE);
             } else {
                 if ($fileSize >= $this->_getUnitSize('MEGABYTE')) {
                     $m->setType(Zend_Measure_Binary::MEGABYTE);
                 } else {
                     if ($fileSize >= $this->_getUnitSize('KILOBYTE')) {
                         $m->setType(Zend_Measure_Binary::KILOBYTE);
                     }
                 }
             }
         }
     } elseif ($norm === 'si') {
         if ($fileSize >= $this->_getUnitSize('TERABYTE_SI')) {
             $m->setType(Zend_Measure_Binary::TERABYTE_SI);
         } else {
             if ($fileSize >= $this->_getUnitSize('GIGABYTE_SI')) {
                 $m->setType(Zend_Measure_Binary::GIGABYTE_SI);
             } else {
                 if ($fileSize >= $this->_getUnitSize('MEGABYTE_SI')) {
                     $m->setType(Zend_Measure_Binary::MEGABYTE_SI);
                 } else {
                     if ($fileSize >= $this->_getUnitSize('KILOBYTE_SI')) {
                         $m->setType(Zend_Measure_Binary::KILOBYTE_SI);
                     }
                 }
             }
         }
     } elseif ($norm === 'iec') {
         if ($fileSize >= $this->_getUnitSize('TEBIBYTE')) {
             $m->setType(Zend_Measure_Binary::TEBIBYTE);
         } else {
             if ($fileSize >= $this->_getUnitSize('GIBIBYTE')) {
                 $m->setType(Zend_Measure_Binary::GIBIBYTE);
             } else {
                 if ($fileSize >= $this->_getUnitSize('MEBIBYTE')) {
                     $m->setType(Zend_Measure_Binary::MEBIBYTE);
                 } else {
                     if ($fileSize >= $this->_getUnitSize('KIBIBYTE')) {
                         $m->setType(Zend_Measure_Binary::KIBIBYTE);
                     }
                 }
             }
         }
     }
     return $m->toString($precision);
 }
开发者ID:br00k,项目名称:tnc-web,代码行数:91,代码来源:FileSize.php

示例12: filter

 /**
  * Defined by Zend_Filter_Interface
  *
  * Normalizes the given input
  *
  * @param  string $value Value to normalized
  * @return string|array The normalized value
  */
 public function filter($value)
 {
     if ($this->_options['date_format'] === null && strpos($value, ':') !== false) {
         // Special case, no date format specified, detect time input
         return Zend_Locale_Format::getTime($value, $this->_options);
     } else {
         if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) {
             // Detect date or time input
             return Zend_Locale_Format::getDate($value, $this->_options);
         } else {
             if ($this->_options['precision'] === 0 && Zend_Locale_Format::isInteger($value, $this->_options)) {
                 // Detect integer
                 return Zend_Locale_Format::getInteger($value, $this->_options);
             } else {
                 if ($this->_options['precision'] === null && Zend_Locale_Format::isFloat($value, $this->_options)) {
                     // Detect float
                     return Zend_Locale_Format::getFloat($value, $this->_options);
                 } else {
                     if (Zend_Locale_Format::isNumber($value, $this->_options)) {
                         // Detect all other numbers
                         return Zend_Locale_Format::getNumber($value, $this->_options);
                     }
                 }
             }
         }
     }
     return $value;
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:36,代码来源:LocalizedToNormalized.php

示例13: calculajurosAction

 public function calculajurosAction()
 {
     Zend_Layout::getMvcInstance()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $post = $this->getRequest()->getPost();
     $id = $post['id'];
     $data_devolucao = $post['data'];
     if (is_numeric($data = $this->facade->calculaJurosBusiness($id, $data_devolucao))) {
         $locale = new Zend_Locale('pt_BR');
         echo "{'valor':'" . Zend_Locale_Format::getFloat($data, array('locale' => $locale, 'precision' => 1)) . "'}";
     } else {
         echo "{'valor':''}";
     }
 }
开发者ID:nishantcbse,项目名称:zf-design-patterns-sample,代码行数:14,代码来源:EmprestimoController.php

示例14: filter

 /**
  * Defined by Zend_Filter_Interface
  *
  * Returns (float) $value
  *
  * @param  string $value
  * @return float
  */
 public function filter($value)
 {
     return (float) Zend_Locale_Format::getFloat($value, $this->_options);
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:12,代码来源:Float.php

示例15: parseValue

 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $ps_value = trim($ps_value);
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('minValue', 'maxValue', 'mustNotBeBlank'));
     if (strlen($ps_value) == 0) {
         if ((bool) $va_settings['mustNotBeBlank']) {
             $this->postError(1970, _t('%1 must not be empty', $pa_element_info['displayLabel']), 'CurrencyAttributeValue->parseValue()');
             return false;
         }
         return null;
     }
     // it's either "<something><decimal>" ($1000) or "<decimal><something>" (1000 EUR) or just "<decimal>" with an implicit <something>
     // either
     if (preg_match("!^([^\\d]+)([\\d\\.\\,]+)\$!", trim($ps_value), $va_matches)) {
         $vs_decimal_value = $va_matches[2];
         $vs_currency_specifier = trim($va_matches[1]);
         // or 1
     } else {
         if (preg_match("!^([\\d\\.\\,]+)([^\\d]+)\$!", trim($ps_value), $va_matches)) {
             $vs_decimal_value = $va_matches[1];
             $vs_currency_specifier = trim($va_matches[2]);
             // or 2
         } else {
             if (preg_match("!(^[\\d\\,\\.]+\$)!", trim($ps_value), $va_matches)) {
                 $vs_decimal_value = $va_matches[1];
                 $vs_currency_specifier = null;
                 // derp
             } else {
                 $this->postError(1970, _t('%1 is not a valid currency value; be sure to include a currency symbol', $pa_element_info['displayLabel']), 'CurrencyAttributeValue->parseValue()');
                 return false;
             }
         }
     }
     if (!$vs_currency_specifier) {
         // this respects the global UI locale which is set using Zend_Locale
         $o_currency = new Zend_Currency();
         $vs_currency_specifier = $o_currency->getShortName();
     }
     // get UI locale from registry and convert string to actual php float
     // based on rules for this locale (e.g. most non-US locations use 10.000,00 as notation)
     if (Zend_Registry::isRegistered("Zend_Locale")) {
         $o_locale = Zend_Registry::get('Zend_Locale');
     } else {
         $o_locale = new Zend_Locale('en_US');
     }
     try {
         $vn_value = Zend_Locale_Format::getFloat($vs_decimal_value, array('locale' => $o_locale, 'precision' => 2));
     } catch (Zend_Locale_Exception $e) {
         $this->postError(1970, _t('%1 does not use a valid decimal notation for your locale', $pa_element_info['displayLabel']), 'CurrencyAttributeValue->parseValue()');
         return false;
     }
     switch ($vs_currency_specifier) {
         case '$':
             $o_config = Configuration::load();
             $vs_currency_specifier = ($vs_dollars_are_this = $o_config->get('default_dollar_currency')) ? $vs_dollars_are_this : 'USD';
             break;
         case '¥':
             $vs_currency_specifier = 'JPY';
             break;
         case '£':
             $vs_currency_specifier = 'GBP';
             break;
         case '€':
             $vs_currency_specifier = 'EUR';
             break;
         default:
             $vs_currency_specifier = strtoupper($vs_currency_specifier);
             break;
     }
     if (strlen($vs_currency_specifier) != 3) {
         $this->postError(1970, _t('Currency specified for %1 does not appear to be valid', $pa_element_info['displayLabel']), 'CurrencyAttributeValue->parseValue()');
         return false;
     }
     if ($vn_value < 0) {
         $this->postError(1970, _t('%1 must not be negative', $pa_element_info['displayLabel']), 'CurrencyAttributeValue->parseValue()');
         return false;
     }
     if ($vn_value < floatval($va_settings['minValue'])) {
         // value is too low
         $this->postError(1970, _t('%1 must be at least %2', $pa_element_info['displayLabel'], $va_settings['minValue']), 'CurrencyAttributeValue->parseValue()');
         return false;
     }
     if (floatval($va_settings['maxValue']) > 0 && $vn_value > floatval($va_settings['maxValue'])) {
         // value is too high
         $this->postError(1970, _t('%1 must be less than %2', $pa_element_info['displayLabel'], $va_settings['maxValue']), 'CurrencyAttributeValue->parseValue()');
         return false;
     }
     return array('value_longtext1' => $vs_currency_specifier, 'value_decimal1' => $vn_value);
 }
开发者ID:samrahman,项目名称:providence,代码行数:89,代码来源:CurrencyAttributeValue.php


注:本文中的Zend_Locale_Format::getFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。