Javascript Date String Parsing

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • dayjs

    ⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API

    This hints that, behind the scenes, Day.js is doing some extra data validation and parsing, but ultimately just using a Date object for its parsing. Since Day.js is open source we can peek behind the scenes and confirm this is true.

  • re2c

    Lexer generator for C, C++, Go and Rust.

    First, the implementation of strtotime is a textbook study in why other people's C code is not where you want to spend time. You can see the guts of the implementation logic here. This isn't stock C code -- it's code for a system called re2c. This system allows you to write regular expressions in a custom DSL (domain specific language), and then transform/compile those regular expressions down to C programs (also C++ and Go) that will execute those regular expressions. Something in PHP's make file uses this parse_date.re file to generate parse_date.c. If you don't realize parse_date.c is a generated file, this can be extremely rough going. If you've not familiar with re2c is can be regular rough going. We leave further exploration as an exercise for the reader -- an exercise we haven't taken ourself.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • moment

    Parse, validate, manipulate, and display dates in javascript.

    The moment library is one of the most popular date libraries for javascript, even if its developers have stepped away from it and consider it "finished". Let's see how it handles abbreviated ISO date strings.

  • date-fns

    ⏳ Modern JavaScript date utility library ⌛️

    What this means in practice we'll leave as an exercise for the reader -- for the general case this means passing in a new Date instance.

  • Luxon

    ⏱ A library for working with dates and times in JS

    The luxon date library, (created by one of the maintainers of moment ) has an different approach.

  • PHPT

    The PHP Interpreter

    First, the implementation of strtotime is a textbook study in why other people's C code is not where you want to spend time. You can see the guts of the implementation logic here. This isn't stock C code -- it's code for a system called re2c. This system allows you to write regular expressions in a custom DSL (domain specific language), and then transform/compile those regular expressions down to C programs (also C++ and Go) that will execute those regular expressions. Something in PHP's make file uses this parse_date.re file to generate parse_date.c. If you don't realize parse_date.c is a generated file, this can be extremely rough going. If you've not familiar with re2c is can be regular rough going. We leave further exploration as an exercise for the reader -- an exercise we haven't taken ourself.

  • locutus

    Bringing stdlibs of other programming languages to JavaScript for educational purposes

    This package includes an implementation of PHP's strtotime function. While it's not a direct port of the re2c PHP regular expressions, it does seem to handle the date formats we've used in this article. A program like this

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts