File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ public static function ptDate2IsoDate($date)
171171 $ fDate = explode ('/ ' , $ date );
172172
173173 if (count ($ fDate ) < 3 ) {
174- $ fDate = $ date ;
174+ return null ;
175175 } else {
176176 if (strlen ($ fDate [2 ])<4 ) {
177177 if (intval ($ fDate [2 ])>30 ) {
Original file line number Diff line number Diff line change @@ -174,4 +174,19 @@ public function testMaskCnpj()
174174 $ this ->assertEquals (Helpers::maskCnpj ($ right ), '11.222.333/4444-55 ' );
175175 $ this ->assertNull (Helpers::maskCnpj ($ wrong ));
176176 }
177+
178+ public function testPtDate2IsoDate ()
179+ {
180+ $ date = '01/02/2003 ' ;
181+ $ other_date = '01/02/03 ' ;
182+ $ incomplete_date = '01/02 ' ;
183+ $ another_incomplete_date = '01/2002 ' ;
184+ $ wrong_input = 'string ' ;
185+
186+ $ this ->assertEquals (Helpers::ptDate2IsoDate ($ date ), '2003-02-01 ' );
187+ $ this ->assertEquals (Helpers::ptDate2IsoDate ($ other_date ), '2003-02-01 ' );
188+ $ this ->assertNull (Helpers::ptDate2IsoDate ($ incomplete_date ));
189+ $ this ->assertNull (Helpers::ptDate2IsoDate ($ another_incomplete_date ));
190+ $ this ->assertNull (Helpers::ptDate2IsoDate ($ wrong_input ));
191+ }
177192}
You can’t perform that action at this time.
0 commit comments