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

nanotime(NA) should not return a nanotime #26

Closed
lsilvest opened this issue Jun 5, 2017 · 4 comments
Closed

nanotime(NA) should not return a nanotime #26

lsilvest opened this issue Jun 5, 2017 · 4 comments

Comments

@lsilvest
Copy link
Collaborator

@lsilvest lsilvest commented Jun 5, 2017

> nanotime(NA)
[1] "1677-09-21T00:12:43.145224192+00:00"
@lsilvest
Copy link
Collaborator Author

@lsilvest lsilvest commented Jun 5, 2017

It's actually most likely a formatting issue, but is.na also needs to be defined for nanotime:

> is.na(nanotime(NA))
[1] TRUE
attr(,".S3Class")
[1] "integer64"
attr(,"class")
[1] "nanotime"
attr(,"class")attr(,"package")
[1] "nanotime"
@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jun 6, 2017

Ditto for other non-finite values it seems:

R> nanotime(c(-Inf, NA, NaN, Inf))
[1] "1677-09-21T00:12:43.145224192+00:00" "1677-09-21T00:12:43.145224192+00:00" 
[3] "1677-09-21T00:12:43.145224192+00:00" "1677-09-21T00:12:43.145224192+00:00"
Warning message:
In as.integer64.double(x, keep.names = TRUE) :
  NAs produced by integer64 overflow
R> 

The warning comes from the Inf values.

@lsilvest
Copy link
Collaborator Author

@lsilvest lsilvest commented Jun 7, 2017

Yes, you are right, we need to take care of these other cases too. I'll get a patch together for that.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jun 15, 2017

Now fixed:

R> nanotime(c(-Inf, NA, NaN, Inf))
[1] NA NA NA NA
Warning message:
In as.integer64.double(x, keep.names = TRUE) :
  NAs produced by integer64 overflow
R> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.