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 returns false on 2.0.11

rebelvg opened this issue · comments

Description

Previously on versions prior to 2.0.11 like 2.0.10 or 2.0.9 it was possible to parse strings like Mon Apr 27 18:49:44 2020. On latest 2.0.11 it just returns false.

I'll take a look. Maybe the string falls into categories that are not yet implemented in locutus. PHP's logic is quite difficult to follow.

The parser that was introduced in 2.0.10 release falls with parsing "Apr 27 18" into datetextual category https://github.com/php/php-src/blob/73734eee6ca30953b9725f683738a141b6b28ebf/ext/date/lib/parse_date.re#L1454 so the remaining :49:44 is not recognized as time. I will try to adjust the rule order to get closer to PHP rules.

PHP in turn recognizes it as dateshortwithtimelong, which is not yet supported. I will try to provide support within next days.

Pull request implementing the missing date formats has just been merged to master.

strtotime(new Date().toISOString()) also returns false

@Falseclock this is probably due to yet missing timezone support. I will add some basic support (for Z and [+-]HH:MM) shortly.

The following PR adds initial timezone support #432
Support for full timezone names will be added in separate PR.

For me strtotime is undefined after import. (locutus: "^2.0.14"). [UPDATE: this is because I was importing it from the wrong locates folder, for some reason my IDE thought it was available in strings.]

I'm closing the issue. If you think the issue is not properly solved, please feel free to re-open.