- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
Closed
Description
As Mastodon uses Snowflake IDs for statuses, it is possible to convert a date and time to a Snowflake ID (with a relatively low resolution). Giving users the ability to provide a POSIXct for max_id, min_id, and/or since_id could make it easier to search for posts between two dates/times.
The Python API client does this as well (and I found it very useful!): https://mastodonpy.readthedocs.io/en/stable/01_general.html#snowflake-ids
One way to implement this could be changing handle_params in utils. Converting a POSIXct datetime to a snowflake id can by done by bitshifting the timestamp like this: as.numeric(datetime)*(2^16))*1000
Might make sense to do a is(max_id, "POSIXct") check before converting, like so:
handle_params <- function(params, max_id, since_id, min_id) {
    if (!missing(max_id)) {
        if(is(max_id, "POSIXct")) {
            params$max_id <- as.numeric(max_id)*(2^16))*1000
        } else {
           params$max_id <- max_id
        }
    }
    if (!missing(since_id)) {
        if(is(max_id, "POSIXct")) {
            params$since_id <- as.numeric(since_id)*(2^16))*1000
        } else {
           params$since_id <- since_id
        }
    }
    if (!missing(min_id)) {
        if(is(min_id, "POSIXct")) {
            params$min_id <- as.numeric(min_id)*(2^16))*1000
        } else {
           params$min_id <- min_id
        }
    }
    params
}
Metadata
Metadata
Assignees
Labels
No labels