Make strptime() to check if date string is matching format completely. #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Time::Piece->strptime()
croaks if first argumentSTRING
isn't matching second argumentFORMAT
. For example, following code will croaked:But there are cases that invalid date string is ignored and Time::Piece object is returned regardless to date string.
Case1: Not enough date string
Date string and format are compared from ahead and trailing format specifiers are ignored if date string reached end of string while parsing.
Case2: Empty date string
Empty date string is ignored even if one or more format has been specified.
These behavior is differ from unix strptime(3). Following code can tell us what kind of date string should be treated as invalid:
We expect that
Time::Piece->strptime()
is respecting unix strptime(3) because you did wrote "see strptime man page." in the POD.We also expect that every invalid format date string will be notified via croak.
So my opinion is that
Time::Piece->strptime()
should check if date string has completely satisfied format specifier and croak if not.Regards.