Skip to content

Commit

Permalink
Fixed PHP GH-11854: DateTime:createFromFormat stopped parsing datetim…
Browse files Browse the repository at this point in the history
…e with extra space
  • Loading branch information
derickr committed Aug 3, 2023
1 parent 908f597 commit b1bee70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion parse_date.re
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@ static void timelib_eat_spaces(const char **ptr)
*ptr += 2;
continue;
}
} while (false);
break;
} while (true);
}

static void timelib_eat_until_separator(const char **ptr)
Expand Down
13 changes: 13 additions & 0 deletions tests/c/parse_date_from_format_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3308,3 +3308,16 @@ TEST(parse_date_from_format, bug_gh9700)
test_parse("2022-02-18T00:00:00+01:00[Europe/Berlin]", "Y-m-d\\TH:i:sP[e]");
STRCMP_EQUAL("Europe/Berlin", t->tz_info->name);
}

TEST(parse_date_from_format, bug_gh11854)
{
test_parse("Wed Aug 2 08:37:50 2023", "D M d H:i:s Y");
LONGS_EQUAL(0, errors->error_count);
LONGS_EQUAL(0, errors->warning_count);
LONGS_EQUAL(2023, t->y);
LONGS_EQUAL( 8, t->m);
LONGS_EQUAL( 2, t->d);
LONGS_EQUAL( 8, t->h);
LONGS_EQUAL(37, t->i);
LONGS_EQUAL(50, t->s);
}

0 comments on commit b1bee70

Please sign in to comment.