rok commented on a change in pull request #11105:
URL: https://github.com/apache/arrow/pull/11105#discussion_r711650841



##########
File path: r/tests/testthat/test-dplyr-string-functions.R
##########
@@ -719,6 +719,69 @@ test_that("errors in strptime", {
   )
 })
 
+test_that("strftime", {
+  skip_on_os("windows") # https://issues.apache.org/jira/browse/ARROW-13168
+
+  # TODO: consider reevaluating this workaround after ARROW-12980
+  withr::local_timezone("UTC")
+  times <- tibble(x = c(lubridate::ymd_hms("2018-10-07 19:04:05"), NA))
+  seconds <- tibble(x = c("05.000000", NA))
+  formats_minus_c <- "%a %A %w %d %b %B %m %y %Y %H %I %p %M %z %Z %j %U %W %x 
%X %% %G %V %u"
+  formats <- paste(formats_minus_c, "%c")
+
+  expect_dplyr_equal(
+    input %>%
+      mutate(x = strftime(x, format = formats)) %>%
+      collect(),
+    times
+  )
+
+  withr::with_timezone("Pacific/Marquesas",
+   expect_dplyr_equal(
+      input %>%
+        mutate(x = strftime(x, format = formats)) %>%
+        collect(),
+      times
+    )
+  )
+
+  expect_dplyr_equal(
+    input %>%
+      mutate(x = strftime(x, format = formats_minus_c, tz = 
"Pacific/Marquesas")) %>%
+      collect(),
+    times
+  )
+
+  withr::with_locale(new = c("LC_TIME" = "C"),
+    expect_dplyr_equal(
+      input %>%
+        mutate(x = strftime(x, format = "%c", tz = "Pacific/Marquesas")) %>%
+        collect(),
+      times
+    )
+  )

Review comment:
       I can't quite explain why, but it happens on my laptop. Could it be that 
strftime is using locale different from the one we use here 
(`Sys.getlocale("LC_TIME")`)?

##########
File path: r/tests/testthat/test-dplyr-string-functions.R
##########
@@ -719,6 +719,69 @@ test_that("errors in strptime", {
   )
 })
 
+test_that("strftime", {
+  skip_on_os("windows") # https://issues.apache.org/jira/browse/ARROW-13168
+
+  # TODO: consider reevaluating this workaround after ARROW-12980
+  withr::local_timezone("UTC")
+  times <- tibble(x = c(lubridate::ymd_hms("2018-10-07 19:04:05"), NA))
+  seconds <- tibble(x = c("05.000000", NA))
+  formats_minus_c <- "%a %A %w %d %b %B %m %y %Y %H %I %p %M %z %Z %j %U %W %x 
%X %% %G %V %u"
+  formats <- paste(formats_minus_c, "%c")
+
+  expect_dplyr_equal(
+    input %>%
+      mutate(x = strftime(x, format = formats)) %>%
+      collect(),
+    times
+  )
+
+  withr::with_timezone("Pacific/Marquesas",
+   expect_dplyr_equal(
+      input %>%
+        mutate(x = strftime(x, format = formats)) %>%
+        collect(),
+      times
+    )
+  )
+
+  expect_dplyr_equal(
+    input %>%
+      mutate(x = strftime(x, format = formats_minus_c, tz = 
"Pacific/Marquesas")) %>%
+      collect(),
+    times
+  )
+
+  withr::with_locale(new = c("LC_TIME" = "C"),
+    expect_dplyr_equal(
+      input %>%
+        mutate(x = strftime(x, format = "%c", tz = "Pacific/Marquesas")) %>%
+        collect(),
+      times
+    )
+  )

Review comment:
       It appears R's strftime interprets `%c` differently as `date.h` we use 
in arrow in certain locales and timezones?
   Sometimes it's `"%a %b %e %H:%M:%S %Y"` and sometimes `"%a %b %e %H:%M:%S %Y 
%Z"`.
   Could also just be my laptop. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to