[Haskell-cafe] Looking for JavaScript(V8)-compilant parser

Javran Cheng javran.c at gmail.com
Tue Feb 19 01:00:16 UTC 2019


Hi Cafe,

tl;dr: I'm wondering if there are existing parsers for parsing any
dateString that can be accepted by `Date.parse` of JavaScript(V8).
The input looks like "Fri, 08 February 2019 12:34:56 +0900".

At first I checked [MDN](
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)
and
turns out it's very close to [IETF-compliant RFC 2822 timestamps](
https://tools.ietf.org/html/rfc2822#page-14), but not quite:
as I then found [hsemail](
http://hackage.haskell.org/package/hsemail-2/docs/Text-Parsec-Rfc2822.html)
to be promising,
but it rejected "Fri, 08 February 2019 12:34:56 +0900" but accepted "Fri,
08 Feb 2019 12:34:56 +0900" (notice that RFC2822 does not accept full month
name).

Refering to language spec doesn't help (
http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.4.2), as it
doesn't mention RFC2822 at all.
So it seems `Data.parse` accepts a superset of RFC2822 and a version of
ISO8601 (as described in MDN above) but I'm not sure what exactly
is the accepting set of inputs.

Before I start working on a quick and dirty solution (it should work
patching hsemail to accept full month name)
I want to know if there are existing parsers for this purpose?

Thanks!
-- 
Javran (Fang) Cheng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190218/c1faf716/attachment.html>


More information about the Haskell-Cafe mailing list