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

fix date comparison #368

Merged
merged 2 commits into from
Mar 8, 2018
Merged

fix date comparison #368

merged 2 commits into from
Mar 8, 2018

Conversation

b1conrad
Copy link
Member

@b1conrad b1conrad commented Mar 7, 2018

this seems to work and doesn't break any pre-existing tests

@farskipper
Copy link
Member

Good catch. Yes parseFloat is too permissive.

I think we should use _.toNumber. Here's how it works:
First it trims white space off the front and end of the string. Then it checks for hex, octal and binary number formats. Then it falls back on javascripts Number(string) type coercion which is stricter than parseFloat

"" -> 0

"2018-03-07" -> null

"1,000" -> null // should we allow commas?

"   123.45 " -> 123.45
"   123 .45 " -> null // no spaces in the numbers
"+5" -> 5
"-5" -> -5

"0xAF" -> 175    // hex
"0o72" -> 58     // octal
"0b01101" -> 13  // binary

@b1conrad
Copy link
Member Author

b1conrad commented Mar 8, 2018

Perfect! Many thanks, Matthew. Let's get this in soon with a minor version number bump

@farskipper farskipper merged commit 1deb822 into master Mar 8, 2018
@farskipper farskipper deleted the date_comparison branch March 8, 2018 16:26
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