Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Piece.xs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,12 @@ _strptime(pTHX_ const char *buf, const char *fmt, struct tm *tm, int *got_GMT)
*/
ptr = fmt;
while (*ptr != 0) {
if (*buf == 0)
break;
if (*buf == 0) {
/* trailing whitespace is allowed */
while (isspace((unsigned char)*ptr))
ptr++;
return (*ptr == 0) ? (char *)buf : 0;
}

c = *ptr++;

Expand Down
15 changes: 14 additions & 1 deletion t/02core.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 96;
use Test::More tests => 98;

my $is_win32 = ($^O =~ /Win32/);
my $is_qnx = ($^O eq 'qnx');
Expand Down Expand Up @@ -227,3 +227,16 @@ cmp_ok(
951827696
);

eval { Time::Piece->strptime("2014", '%Y%m') };
like(
$@,
qr/Error parsing time/,
"croak if passed string wasn't enough to match with format"
);

eval { Time::Piece->strptime("", '%y') };
like(
$@,
qr/Error parsing time/,
"croak if empty string passed to strptime with non-empty format"
);