poco icon indicating copy to clipboard operation
poco copied to clipboard

Poco::DateTimeParser::tryParse issue

Open micheleselea opened this issue 9 years ago • 4 comments

Hi all, if you use DateTimeParser::tryParse to parse an invalida datetime, often you obtain true but the datetime is invalid

    Poco::DateTime dt;
int tz = 0;
if (Poco::DateTimeParser::tryParse("%d/%m/%Y", "some invalid date time", dt, tz)) {
         //you obtain true but with dt with a negative value
}

micheleselea avatar Apr 27 '16 07:04 micheleselea

Quote from the document: " All parsing methods do their best to parse a meaningful result, even from malformed input strings. I guess that's why that function doesn't check the input strictly and it is an expected behavior.

aaron0x avatar Apr 27 '16 14:04 aaron0x

The parsing code in DateTimeParser could use some improvement. For example, currently it basically ignores all non-format characters in the format string. Also, some better range checking may be in order. See also #569

obiltschnig avatar Apr 27 '16 18:04 obiltschnig

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Aug 26 '22 03:08 github-actions[bot]

#569

aleks-f avatar Aug 26 '22 10:08 aleks-f