From 1c4ef695335167218b8bc22179effd2329e607fb Mon Sep 17 00:00:00 2001 From: Tim Schatto-Eckrodt Date: Tue, 12 Mar 2024 23:49:25 +0100 Subject: [PATCH] Add conversion for snowflake ids from POSIXct --- R/utils.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/R/utils.R b/R/utils.R index 568c54f..00d48b4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -237,15 +237,23 @@ rtoot_ask <- function(prompt = "enter authorization code: ", pass = TRUE, check_ return(passFun(prompt = prompt)) } +handle_id <- function(x) { + ## Convert x to snowflake id if it is POSIXct + if (is (x, "POSIXct")) { + return(as.numeric(x)*(2^16))*1000) + } + x +} + handle_params <- function(params, max_id, since_id, min_id) { if (!missing(max_id)) { - params$max_id <- max_id + params$max_id <- handle_id(max_id) } if (!missing(since_id)) { - params$since_id <- since_id + params$since_id <- handle_id(since_id) } if (!missing(min_id)) { - params$min_id <- min_id + params$min_id <- handle_id(min_id) } params }