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

Keep milliseconds in activityTime value #314

Closed
VadimChernik opened this issue May 14, 2020 · 2 comments
Closed

Keep milliseconds in activityTime value #314

VadimChernik opened this issue May 14, 2020 · 2 comments
Assignees

Comments

@VadimChernik
Copy link

Hi Mark,

I have a little issue with iso8601_to_r function from utilities.R.
As I see, this function changes a Timestamp value into POSIXct format, but it keeps only seconds.

x <- as.POSIXct(gsub("\....Z$","","2014-10-02T15:01:23.045123456Z"), format = "%Y-%m-%dT%H:%M:%S", tz = "UTC")
x
[1] "2014-10-02 15:01:23 UTC"
format(x, "%Y-%m-%d %H:%M:%OS6")
[1] "2014-10-02 15:01:23.000000"

Is it possible to keep milliseconds from the original value?
I've tried to use the format "%Y-%m-%dT%H:%M:%OS" while changing the original Timestamp value. And I got the desired result.

x <- as.POSIXct(gsub("\....Z$","","2014-10-02T15:01:23.045123456Z"), format = "%Y-%m-%dT%H:%M:%OS", tz = "UTC")
x
[1] "2014-10-02 15:01:23 UTC"
format(x, "%Y-%m-%d %H:%M:%OS6")
[1] "2014-10-02 15:01:23.045123"

I think this fix will be helpful for users if they want to keep a sequence of interactions.

@VadimChernik VadimChernik changed the title Keep milleseconds in activityTime value Keep milliseconds in activityTime value May 14, 2020
@MarkEdmondson1234
Copy link
Collaborator

MarkEdmondson1234 commented May 16, 2020

Thanks, I have updated the parsing to

#' iso8601 timestamp to R
#' @noRd
iso8601_to_r <- function(x){
  as.POSIXct(gsub("\\....Z$","",x), format = "%Y-%m-%dT%H:%M:%OS", tz = "UTC")
}

The timestamps are available to millisecond level but you will need to set your R options to see them e.g. options(digits.secs=3)

@VadimChernik
Copy link
Author

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants