Development

/branches/1.3/lib/helper/NumberHelper.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/helper/NumberHelper.php

Revision 23810, 1.0 kB (checked in by Kris.Wallsmith, 4 years ago)

[1.3] set svn:eol-style property to native and svn:keywords property to Id on all .php files

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * NumberHelper.
13  *
14  * @package    symfony
15  * @subpackage helper
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19
20 function format_number($number, $culture = null)
21 {
22   if (null === $number)
23   {
24     return null;
25   }
26
27   $numberFormat = new sfNumberFormat(_current_language($culture));
28
29   return $numberFormat->format($number);
30 }
31
32 function format_currency($amount, $currency = null, $culture = null)
33 {
34   if (null === $amount)
35   {
36     return null;
37   }
38
39   $numberFormat = new sfNumberFormat(_current_language($culture));
40
41   return $numberFormat->format($amount, 'c', $currency);
42 }
43
44 function _current_language($culture)
45 {
46   return $culture ? $culture : sfContext::getInstance()->getUser()->getCulture();
47 }
48
Note: See TracBrowser for help on using the browser.