Convert POSIXct to KuCoin Server Time
Source:R/utils_time_convert_kucoin.R
time_convert_to_kucoin.RdConverts a POSIXct object into a UNIX timestamp in the specified unit, compatible with KuCoin's server time requirements.
Usage
time_convert_to_kucoin(datetime, unit = c("ms", "ns", "s"))Details
Workflow Overview
Input Validation: Ensures
datetimeis a POSIXct object, aborting if not.Unit Matching: Validates
unitagainst allowed options ("ms","ns","s") usingmatch.arg().Time Conversion: Converts the POSIXct to seconds and scales to the desired unit (milliseconds, nanoseconds, or seconds).
Examples
if (FALSE) { # \dontrun{
# Convert to milliseconds
dt <- as.POSIXct("2023-10-31 16:00:00", tz = "UTC")
time_convert_to_kucoin(datetime = dt, unit = "ms")
# Returns 1698777600000
# Convert to nanoseconds
time_convert_to_kucoin(datetime = dt, unit = "ns")
# Returns 1698777600000000000
} # }