Skip to content

Commit 0dda3ea

Browse files
authored
Add conversion for snowflake ids from POSIXct fix #153 (#154)
Add Tim Schatto-Eckrodt as contributor to DESCRIPTION
1 parent 922eb95 commit 0dda3ea

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Version: 0.3.4
44
Authors@R:
55
c(person("David", "Schoch", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2952-4812")),
66
person("Chung-hong", "Chan", ,"[email protected]", role = c("aut"), comment = c(ORCID = "0000-0002-6232-7530")),
7-
person("Johannes", "Gruber", ,"[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0001-9177-1772")))
7+
person("Johannes", "Gruber", ,"[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0001-9177-1772")),
8+
person("Tim", "Schatto-Eckrodt", ,"[email protected]", role = c("ctb"), comment = c(ORCID = "0000-0003-1658-4373")))
89
Description: An implementation of calls designed to collect and organize Mastodon data via its Application Program Interfaces (API), which can be found at the following URL: <https://docs.joinmastodon.org/>.
910
License: MIT + file LICENSE
1011
URL: https://gesistsa.github.io/rtoot/, https://github.com/gesistsa/rtoot/

R/utils.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,23 @@ rtoot_ask <- function(prompt = "enter authorization code: ", pass = TRUE, check_
237237
return(passFun(prompt = prompt))
238238
}
239239

240+
handle_id <- function(x) {
241+
## Convert x to snowflake id if it is POSIXct
242+
if (is(x, "POSIXct")) {
243+
return(as.numeric(x) * (2^16) * 1000)
244+
}
245+
x
246+
}
247+
240248
handle_params <- function(params, max_id, since_id, min_id) {
241249
if (!missing(max_id)) {
242-
params$max_id <- max_id
250+
params$max_id <- handle_id(max_id)
243251
}
244252
if (!missing(since_id)) {
245-
params$since_id <- since_id
253+
params$since_id <- handle_id(since_id)
246254
}
247255
if (!missing(min_id)) {
248-
params$min_id <- min_id
256+
params$min_id <- handle_id(min_id)
249257
}
250258
params
251259
}

0 commit comments

Comments
 (0)