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

Date() does not validate Unix timestamp with fractional seconds (decimals) #789

Closed
galenandrew opened this issue Dec 29, 2015 · 4 comments · Fixed by #791
Closed

Date() does not validate Unix timestamp with fractional seconds (decimals) #789

galenandrew opened this issue Dec 29, 2015 · 4 comments · Fixed by #791
Assignees
Labels
bug Bug or defect
Milestone

Comments

@galenandrew
Copy link
Contributor

Timestamps generated with fractional seconds (i.e. date +%s.%N => 1451427344.877632802) do not validate as dates.

This appears to be a result of Hoek.isInteger(value) on /lib/date.js#L61.

@Marsup
Copy link
Collaborator

Marsup commented Dec 29, 2015

Javascript would truncate it anyway, not sure it's worth accepting something that'll get lost in the conversion.

@galenandrew
Copy link
Contributor Author

It getting truncated should not be reason for rejecting the value as invalid, but rather simply a known behavior (developer's responsibility…not the project's). The fact is that date +%s.%N produces a valid unix timestamp that Joi rejects.

I'll work on a PR for this, but wanted to open the issue so there was visibility as well.

@Marsup
Copy link
Collaborator

Marsup commented Dec 30, 2015

And you did well checking before making a PR, which is welcome indeed.

@Marsup Marsup added the bug Bug or defect label Dec 30, 2015
@Marsup Marsup self-assigned this Dec 30, 2015
galenandrew added a commit to galenandrew/joi that referenced this issue Dec 30, 2015
galenandrew added a commit to galenandrew/joi that referenced this issue Dec 31, 2015
galenandrew added a commit to galenandrew/joi that referenced this issue Dec 31, 2015
galenandrew added a commit to galenandrew/joi that referenced this issue Dec 31, 2015
galenandrew added a commit to galenandrew/joi that referenced this issue Dec 31, 2015
galenandrew added a commit to galenandrew/joi that referenced this issue Dec 31, 2015
@galenandrew
Copy link
Contributor Author

@Marsup PR #791 submitted. Due to the differences between javascript timestamps and unix timestamps, I've added additional support for both values.

@Marsup Marsup added this to the 7.2.0 milestone Jan 6, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants