$t->can_ok(new FuzzyDateTime(), 'getDateTime', 'Object FuzzyDateTime has a method named: getDateTime'); $t->can_ok(new FuzzyDateTime(), 'getDateTimeAsArray', 'Object FuzzyDateTime has a method named: getDateTimeAsArray'); $t->can_ok(new FuzzyDateTime(), 'getDateMasked', 'Object FuzzyDateTime has a method named: getDateMasked'); $t->can_ok(new FuzzyDateTime(), '__ToString', 'Object FuzzyDateTime has a method named: __ToString'); $fdt = new FuzzyDateTime(); $currentDate = $fdt->format('d/m/Y'); $currentDateTime = $fdt->format('d/m/Y H:i:s'); $t->is($fdt->getDateTime(), $currentDate, 'Get the date coming with the FuzzyDateTime object instanciation'); $t->is($fdt->getDateTime(true), $currentDateTime, 'Get the date and time coming with the FuzzyDateTime object instanciation: ok'); $fdt->setStart(false); $t->is($fdt->getStart(), false, 'The start value is False'); $fdt->setMask(32); $t->is($fdt->getMask(), 32, 'The Mask value is 32 (year)'); $fdt = new FuzzyDateTime('1975/02/24 13:12:11'); $testArray = array('year' => 1975, 'month' => 02, 'day' => 24, 'hour' => 13, 'minute' => 12, 'second' => 11); $dateTimeArray = $fdt->getDateTimeAsArray(); $testDate = '24/02/1975'; $testDateTime = '24/02/1975 13:12:11'; $testDateTime2 = '1975/02/24 13:12:11'; $testDateUS = '02/24/1975'; $t->is_deeply($dateTimeArray, $testArray, 'array is the same'); $fdt->setWithTime(true); $t->is($fdt->getDateTime($fdt->getWithTime()), $testDateTime, 'Get the date and time coming with the FuzzyDateTime object instanciation: ok'); $t->is($fdt . ' as string', $testDateTime . ' as string', 'String conversion of FuzzyDateTime object is correct'); $fdt->setDateFormat('m/d/Y'); $t->is($fdt->getDateTime(false), $testDateUS, 'New US date formating correctly applied'); $t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Full date: Extraction of date from array succeeded !'); $testArray['second'] = ''; $testDateTime2 = '1975/02/24 13:12:59'; $t->is(FuzzyDateTime::getDateTimeStringFromArray($testArray, false, $fdt->getWithTime()), $testDateTime2, 'Date without seconds - start flag set at false: Extraction of date from array succeeded !'); $testArray['minute'] = '';