peachpie icon indicating copy to clipboard operation
peachpie copied to clipboard

Fix strtotime

Open Indigo744 opened this issue 5 years ago • 1 comments

strtotime fails with

  • strtotime("first monday of 2020-01")

And has wrong result for:

  • strtotime("2020-01")

I only added the test cases for now, but I have no idea how to tackle this. Any pointers?

Indigo744 avatar Sep 01 '20 19:09 Indigo744

I was checking the issue down to the actual time parser.

  1. The tokens like "first", "monday", etc. are parsed at Generators/StrToTime.lex (generated into Parsers\StrToTimeScanner.cs). Seems the parser does not know the "of" token at all.

  2. "2020-01" is also an unknown combination in the parser, it expects three numbers, not just two.

So it is possible to update the parser (StrToTime.lex) with the new "grammar". Technically it is just a lexer, so it's very simple pattern matching

jakubmisek avatar Oct 19 '20 11:10 jakubmisek