Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(parse-iso-date): Convert to TypeScript #2080

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

0livare
Copy link
Contributor

@0livare 0livare commented Aug 9, 2023

The poor parseIsoDate util was the only file in the repo that hadn't been converted over to TypeScript back in 2020. In addition, it was written in a way that was hard to read and harder to understand. It also had the linter disabled for the entire file.

This pull request aims to fix all those issues, while maintaining exactly the same functionality.

To ensure the same functionality, before making any changes I ported over the tests from the original source of the parseIsoDate function. Many of those tests no longer passed because of previous changes made to the function, but I modified them to match the module's current functionality. With the tests in place, I was then able to refactor the module and ensure that the functionality remained identical.

Adapted from: https://github.com/csnover/js-iso8601/blob/master/tests/test.js

NOTE: Many of these tests do not currently pass because of
modifications that have been made to parseIsoDate.

Those changes include (but probably aren't limited to):

  - The regex has been modified to add more "?" conditionals to make the
    parsing more forgiving
  - Times that lack a time zone specifier are treated as local time
All tests now pass with the current implementation of
parseIsoDate.
It was the only JS file remaining in the repo, it was also written in
an old, difficult to read style of JavaScript

The functionality remains identical.
Copy link
Owner

@jquense jquense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome thanks!

@jquense jquense merged commit 41b9c58 into jquense:master Aug 17, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants