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

ISO date format #21

Closed
bergant opened this issue Dec 27, 2014 · 6 comments
Closed

ISO date format #21

bergant opened this issue Dec 27, 2014 · 6 comments

Comments

@bergant
Copy link

bergant commented Dec 27, 2014

Hi!

On windows (R version 3.0.2) I get only empty graph. After some debugging I am pretty sure it is because "my" format.POSIXct returns empty string when formated as "%F".

Maybe the asISO8601Time function in dygraphs/R/utils.R could be changed to

asISO8601Time <- function(x) {
  if (!inherits(x, "POSIXct"))
    x <- as.POSIXct(x)
  format(x, format="%Y-%m-%dT%H:%M:%SZ")
}

For now my workaround is:

res1 <- dygraph(nhtemp, main = "New Haven Temperatures",  ylab = "Temp (F)") 
res1$x$data[[1]] <- format( attr(res1$x, "time"), "%Y-%m-%dT%H:%M:%SZ")
res1

Dare

@jjallaire
Copy link
Member

I am hesitant to mess with that function without knowing exactly what all the implications are (as I had trouble with date handling in JavaScript until the function was implemented as it currently is). It would also be helpful to have a full example and further explanation of the problem and your solution.

@bergant
Copy link
Author

bergant commented Dec 27, 2014

Example:

test1 <- xts( c(1, 2), as.POSIXct(c("2014-01-01", "2014-02-01"), tz = "GMT" ))
res1 <- dygraph(test1)
str(res1$x$data)

List of 2
 $ : chr [1:2] "" ""
 $ : num [1:2] 1 2

I think that changing

format(x, format="%FT%H:%M:%SZ", tz='GMT')

to

format(x, format="%Y-%m-%dT%H:%M:%SZ", tz='GMT')

should be just fine. Because %F should format date as %Y-%m-%d if implemented right
(as explained in R documentation). I think the problem is that %F is not implemented on windows platform (at least not in R version 3.0.2.).

@jjallaire
Copy link
Member

Okay, I just committed that change to the format specification. Let me know if that resolves the issue on your end.

@bergant
Copy link
Author

bergant commented Dec 29, 2014

It's perfect now. Thanks.

test1 <- xts(c(1,2), as.POSIXct(c("2014-01-01", "2014-02-01"), tz = "GMT" ))
res1 <- dygraph(test1)
str(res1$x$data)

List of 2
 $ : chr [1:2] "2014-01-01T00:00:00Z" "2014-02-01T00:00:00Z"
 $ : num [1:2] 1 2

@ChipMart92
Copy link

Hi, bergant. This might be off topic, but I was hoping I could have your assistance with the XBRL files you posted Earlier. I was wondering how to apply this method to, say another company. Many thanks

@bergant
Copy link
Author

bergant commented Mar 14, 2015

@ChipMart92 I guess this has nothing to do with dygraphs. I have made my e-mail public on my account so you can contact me directly.

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