locutusjs / locutus

Bringing stdlibs of other programming languages to JavaScript for educational purposes

Home Page:https://locutus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

strtotime() has problem such as "-1 day"

Ltre opened this issue · comments

var php = require('phpjs');
php.echo(php.date('Ymd', php.strtotime('20160201 -1 day')));


stmt:  php.strtotime('20160201 -1 day')
result: 1453259446.278

stmt:  php.date('Ymd', php.strtotime('20160201 -1 day'))
result:  20160120


stmt: php.date('Ymd', 1453259446.278)
result:  20160120

it seems the function php.strtotime() has problem for transformation

please fix the BUG

I'm on it. Will take some time, as I'm doing a complete rewrite.

Closing this for now then

Just a small progress update, the new implementation recognizes already majority of the formats supported by php. It still recognizes some formats as combination of several other, so this is currently my task to adjust the recognition to get as close to php as possible. Then it's just the logic to calculate the final timestamp.
I have a lot of unit tests that check the correctness of the recognition.

Sounds great Rafał!