fixed GH #363: DateTimeParser tryParse/parse

This commit is contained in:
Alex Fabijanic 2014-05-22 03:08:41 -05:00
parent c99c776aff
commit 83d11b5a00
6 changed files with 42 additions and 6 deletions

View File

@ -69,6 +69,7 @@ Release 1.5.3 (2014-05-xx)
- fixed GH #154 Add support for MYSQL_TYPE_NEWDECIMAL to Poco::Data::MySQL
- fixed GH #290: Unicode support
- fixed GH #318: Logger local time doesn't automatically account for DST
- fixed GH #363: DateTimeParser tryParse/parse
Release 1.5.2 (2013-09-16)
==========================

View File

@ -46,6 +46,9 @@ namespace Poco {
void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential)
{
if (fmt.empty() || str.empty())
throw SyntaxException("Empty string.");
int year = 0;
int month = 0;
int day = 0;

View File

@ -505,6 +505,37 @@ void DateTimeParserTest::testCustom()
assert (dt.hour() == 12);
assert (dt.minute() == 30);
assert (dt.second() == 0);
assert (!DateTimeParser::tryParse("%h:%M %a", "", dt, tzd));
assert (!DateTimeParser::tryParse("", "12:30 PM", dt, tzd));
assert (!DateTimeParser::tryParse("", "", dt, tzd));
try
{
DateTimeParser::parse("%h:%M %a", "", tzd);
fail ("must fail");
}
catch (SyntaxException&)
{
}
try
{
DateTimeParser::parse("", "12:30 PM", tzd);
fail ("must fail");
}
catch (SyntaxException&)
{
}
try
{
DateTimeParser::parse("", "", tzd);
fail ("must fail");
}
catch (SyntaxException&)
{
}
}

View File

@ -49,7 +49,7 @@ void DirectoryIteratorsTest::testDirectoryIterator()
result.push_back(file);
}
assertEquals(7, result.size());
assertEquals(7, (long) result.size());
}
@ -68,7 +68,7 @@ void DirectoryIteratorsTest::testSortedDirectoryIterator()
result.push_back(file);
}
assertEquals(7, result.size());
assertEquals(7, (long) result.size());
assertEquals("first", result[0]);
assertEquals("1", result[1]);
assertEquals("2", result[2]);
@ -94,7 +94,7 @@ void DirectoryIteratorsTest::testSimpleRecursiveDirectoryIterator()
result.push_back(file);
}
assertEquals(20, result.size());
assertEquals(20, (long) result.size());
}
@ -113,7 +113,7 @@ void DirectoryIteratorsTest::testSiblingsFirstRecursiveDirectoryIterator()
result.push_back(file);
}
assertEquals(20, result.size());
assertEquals(20, (long) result.size());
}

View File

@ -969,7 +969,7 @@ void StringTest::testIntToString()
{
char pResult[POCO_MAX_INT_STRING_LEN];
std::size_t sz = POCO_MAX_INT_STRING_LEN;
intToStr(0, 10, pResult, sz, false, sz + 1, ' ');
intToStr(0, 10, pResult, sz, false, (int) sz + 1, ' ');
fail ("must throw RangeException");
} catch (RangeException&) { }
}

View File

@ -71,7 +71,8 @@ AAAIntroduction
- fixed GH #154 Add support for MYSQL_TYPE_NEWDECIMAL to Poco::Data::MySQL
- fixed GH #290: Unicode support
- fixed GH #318: Logger local time doesn't automatically account for DST
- fixed GH #363: DateTimeParser tryParse/parse
!!Incompatible Changes and Possible Transition Issues
- Data::ODBC: UTF-16 Unicode is now directly mapped and recognized as type by ODBC.