Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Commit

Permalink
Parse lookup_status and timeline created_at to dates.
Browse files Browse the repository at this point in the history
Closes #657
  • Loading branch information
llrs committed Feb 23, 2022
1 parent b420ab1 commit 0b3d454
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: rtweet
Title: Collecting Twitter Data
Version: 0.7.0.9012
Version: 0.7.0.9013
Authors@R:
c(person(given = "Michael W.",
family = "Kearney",
Expand Down
4 changes: 4 additions & 0 deletions R/statuses.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ lookup_tweets <- function(statuses, parse = TRUE, token = NULL,

if (parse) {
results <- tweets_with_users(results)
locale <- Sys.getlocale("LC_TIME")
Sys.setlocale("LC_TIME", "C")
results$created_at <- as.POSIXct(results$created_at, format = "%a %b %d %T %z %Y")
Sys.setlocale("LC_TIME", locale)
}
results
}
Expand Down
4 changes: 4 additions & 0 deletions R/timeline.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ get_timeline <- function(user = NULL,
if (parse) {
rt <- do.call("rbind", rt)
rt <- as_tbl(rt)
locale <- Sys.getlocale("LC_TIME")
Sys.setlocale("LC_TIME", "C")
rt$created_at <- as.POSIXct(rt$created_at, format = "%a %b %d %T %z %Y")
Sys.setlocale("LC_TIME", locale)
}

rt
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-statuses.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ test_that("Check that geo works well, #648", {
"930475046530936834", "914607458169081858"))
expect_true(is.list(lu$geo) && !is.data.frame(lu$geo))
})

test_that("Check lookup returns appropiate format, #657", {
lu <- lookup_tweets("1488182699202383875")
expect_s3_class(lu$created_at, "POSIXct")
})

0 comments on commit 0b3d454

Please sign in to comment.