summaryrefslogtreecommitdiff
path: root/framework/I18N
diff options
context:
space:
mode:
authorwei <>2006-04-25 07:01:04 +0000
committerwei <>2006-04-25 07:01:04 +0000
commit8b0c8f0d0557d8ab88409cd9691cd1ee279321d5 (patch)
tree2c570f0d3839089edbb7e53244adcd2db98cb992 /framework/I18N
parent7fa4dd96f1ac0c57e6c67faf9f9dda46f1dd1b89 (diff)
Complete #70, update TDateFormat, NumberFormat add zerofill. Update TDatePicker quickstart doc, I18N quickstart doc.
Diffstat (limited to 'framework/I18N')
-rw-r--r--framework/I18N/TDateFormat.php11
-rw-r--r--framework/I18N/core/DateFormat.php12
-rw-r--r--framework/I18N/core/NumberFormat.php7
-rw-r--r--framework/I18N/core/NumberFormatInfo.php18
4 files changed, 38 insertions, 10 deletions
diff --git a/framework/I18N/TDateFormat.php b/framework/I18N/TDateFormat.php
index 8ebbce5e..0f5507ab 100644
--- a/framework/I18N/TDateFormat.php
+++ b/framework/I18N/TDateFormat.php
@@ -48,10 +48,9 @@ Prado::using('System.I18N.TI18NControl');
* if the Value property is not specified.
* - <b>Pattern</b>, string,
* <br>Gets or sets the formatting pattern. The predefined patterns are
- * 'full date', 'long date', 'medium date', 'short date', 'full time',
- * 'long time', 'medium time', and 'short time'. Custom patterns can
- * specified when the Pattern property does not match the predefined
- * patterns.
+ * 'fulldate', 'longdate', 'mediumdate', 'shortdate', 'fulltime',
+ * 'longtime', 'mediumtime', and 'shorttime'. Custom patterns can specified
+ * when the Pattern property does not match the predefined patterns.
*
* @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004
@@ -69,7 +68,7 @@ class TDateFormat extends TI18NControl
* A set of pattern presets and their respective formatting shorthand.
* @var array
*/
- protected $patternPresets = array(
+ static private $_patternPresets = array(
'fulldate'=>'P','full'=>'P',
'longdate'=>'D','long'=>'d',
'mediumdate'=>'p','medium'=>'p',
@@ -132,7 +131,7 @@ class TDateFormat extends TI18NControl
protected function getPreset($string)
{
$string = strtolower($string);
- foreach($this->patternPresets as $pattern => $preset)
+ foreach(self::$_patternPresets as $pattern => $preset)
{
if($string == $pattern)
return $preset;
diff --git a/framework/I18N/core/DateFormat.php b/framework/I18N/core/DateFormat.php
index 9caca03b..142926f4 100644
--- a/framework/I18N/core/DateFormat.php
+++ b/framework/I18N/core/DateFormat.php
@@ -128,7 +128,12 @@ class DateFormat
if($pattern{0} == "'"
&& $pattern{strlen($pattern)-1} == "'")
{
- $tokens[$i] = preg_replace('/(^\')|(\'$)/','',$pattern);
+ $sub = preg_replace('/(^\')|(\'$)/','',$pattern);
+ $tokens[$i] = str_replace('``````','\'',$sub);
+ }
+ else if($pattern == '``````')
+ {
+ $tokens[$i] = '\'';
}
else
{
@@ -145,7 +150,7 @@ class DateFormat
throw new
Exception('function '.$function.' not found.');
}
- }
+ }
}
return I18N_toEncoding(implode('',$tokens), $charset);
@@ -269,6 +274,7 @@ class DateFormat
$token = null;
$text = false;
+ $pattern = preg_replace("/''/", '``````', $pattern);
for($i = 0; $i < strlen($pattern); $i++)
{
@@ -278,7 +284,7 @@ class DateFormat
}
else
{
- $tokens[] = str_replace("''","'",$token);
+ $tokens[] = str_replace("","'",$token);
$token = $pattern{$i};
}
diff --git a/framework/I18N/core/NumberFormat.php b/framework/I18N/core/NumberFormat.php
index bde87e65..d1184f86 100644
--- a/framework/I18N/core/NumberFormat.php
+++ b/framework/I18N/core/NumberFormat.php
@@ -63,7 +63,7 @@ require_once(dirname(__FILE__).'/util.php');
* $ja = new NumberFormat('ja_JP');
*
* //Japanese currency pattern, and using Japanese Yen symbol
- * $ja->format(123.14,'c','JPY'); //ï¿?123 (Yen 123)
+ * $ja->format(123.14,'c','JPY'); //�?123 (Yen 123)
* </code>
* For each culture, the symbol for each currency may be different.
*
@@ -166,12 +166,17 @@ class NumberFormat
$string = substr($string, 0, $dp);
$integer = '';
+
+ $digitSize = $this->formatInfo->getDigitSize();
+
+ $string = str_pad($string, $digitSize, '0',STR_PAD_LEFT);
$len = strlen($string);
$groupSeparator = $this->formatInfo->GroupSeparator;
$groupSize = $this->formatInfo->GroupSizes;
+
$firstGroup = true;
$multiGroup = is_int($groupSize[1]);
$count = 0;
diff --git a/framework/I18N/core/NumberFormatInfo.php b/framework/I18N/core/NumberFormatInfo.php
index 15b9ee5d..3531cc7f 100644
--- a/framework/I18N/core/NumberFormatInfo.php
+++ b/framework/I18N/core/NumberFormatInfo.php
@@ -324,6 +324,13 @@ class NumberFormatInfo
}
}
}
+
+ if(is_int($decimalPos))
+ $digitPattern = substr($pattern,0,$decimalPos);
+ else
+ $digitPattern = $pattern;
+
+ $digitPattern = preg_replace('/[^0]/','',$digitPattern);
$info['groupPos1'] = $groupPos1;
$info['groupSize1'] = $groupSize1;
@@ -331,6 +338,7 @@ class NumberFormatInfo
$info['groupSize2'] = $groupSize2;
$info['decimalPos'] = $decimalPos;
$info['decimalPoints'] = $decimalPoints;
+ $info['digitSize'] = strlen($digitPattern);
return $info;
}
@@ -365,6 +373,16 @@ class NumberFormatInfo
return $this->pattern['decimalPoints'] = $value;
}
+ function getDigitSize()
+ {
+ return $this->pattern['digitSize'];
+ }
+
+ function setDigitSize($value)
+ {
+ $this->pattern['digitSize'] = $value;
+ }
+
/**
* Gets the string to use as the decimal separator.
* @return string decimal separator.