Last active
February 28, 2016 09:34
-
-
Save mrdwab/a35037e55e4af4451ba9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kobo_time_parser_UTC <- function(instring) { | |
tmp <- gsub("\\.\\d{3}|:", "", instring) | |
tmp <- chartr(" ", "0", format(tmp, justify = "left", width = 22)) | |
as.POSIXct(strptime(tmp, format = "%Y-%m-%dT%H%M%S%z", tz = "UTC")) | |
} | |
kobo_time_parser <- function(indatetime, timezone = Sys.timezone()) { | |
format(kobo_time_parser_UTC(indatetime), tz = timezone, usetz = TRUE) | |
} | |
TIME <- "2015-08-27T13:28:29.000+06:30" | |
kobo_time_parser_UTC(TIME) | |
# [1] "2015-08-27 06:58:29 UTC" | |
kobo_time_parser(TIME) | |
# [1] "2015-08-27 12:28:29 IST" | |
kobo_time_parser(TIME, timezone = "Asia/Rangoon") | |
# [1] "2015-08-27 13:28:29 MMT" | |
kobo_time_parser(TIME, timezone = "America/Los_Angeles") | |
# [1] "2015-08-26 23:58:29 PDT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment