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

Should throw error if the given string is not even a timestring #40

Closed
gjgarryuan opened this issue Mar 28, 2018 · 4 comments
Closed

Should throw error if the given string is not even a timestring #40

gjgarryuan opened this issue Mar 28, 2018 · 4 comments

Comments

@gjgarryuan
Copy link

gjgarryuan commented Mar 28, 2018

I observe that there is already a test case for timestring having unrecognized time unit at:

it('throws an error when an invalid unit is used in the timestring', () => {

However, the lib should do the same if the entire given string is not a timestring at all.

For now (release 5.0.0):

  • timestring('test', 'milliseconds') => 0
  • timestring('0test', 'milliseconds') => Error: The unit [test] is not supported by timestring
@gjgarryuan
Copy link
Author

In addition, it will be great if a method can be exposed to check the validity of a timestring.

@prolink007
Copy link

I am also seeking this functionality.

@prolink007
Copy link

#43 I just submitted a PR to add in this error checking. Let me know if this is what you are desiring too, @garrychnca

@mike182uk
Copy link
Owner

Published #43 in 6.0.0

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

No branches or pull requests

3 participants