Ver Fonte

[Locale] added implementation for minutes and seconds

Eriksen Costa há 14 anos atrás
pai
commit
dadd896915

+ 4 - 2
src/Symfony/Component/Locale/Stub/DateFormat/MinuteTransformer.php

@@ -27,10 +27,12 @@ class MinuteTransformer extends Transformer
     public function getReverseMatchingRegExp($length)
     {
         if (1 == $length) {
-            return '\d{1,2}';
+            $regExp = '\d{1,2}';
         } else {
-            return "\d{$length}";
+            $regExp = '\d{'.$length.'}';
         }
+
+        return $regExp;
     }
 
     public function extractDateOptions($matched, $length)

+ 4 - 2
src/Symfony/Component/Locale/Stub/DateFormat/SecondTransformer.php

@@ -27,10 +27,12 @@ class SecondTransformer extends Transformer
     public function getReverseMatchingRegExp($length)
     {
         if (1 == $length) {
-            return '\d{1,2}';
+            $regExp = '\d{1,2}';
         } else {
-            return "\d{$length}";
+            $regExp = '\d{'.$length.'}';
         }
+
+        return $regExp;
     }
 
     public function extractDateOptions($matched, $length)

+ 8 - 0
tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php

@@ -512,6 +512,14 @@ class StubIntlDateFormatterTest extends LocaleTestCase
             array('y-M-d kk a', '1970-1-1 11 AM', 0),
             array('y-M-d kk a', '1970-1-1 12 AM', 0),
             array('y-M-d kk a', '1970-1-1 23 AM', 0),
+
+            // minutes
+            array('y-M-d HH:m', '1970-1-1 0:1', 60),
+            array('y-M-d HH:mm', '1970-1-1 0:10', 600),
+
+            // seconds
+            array('y-M-d HH:mm:s', '1970-1-1 00:01:1', 61),
+            array('y-M-d HH:mm:ss', '1970-1-1 00:01:10', 70),
         );
     }