Convert KuCoin Server Time to POSIXct
Source:R/utils_time_convert_kucoin.R
time_convert_from_kucoin.Rd
Converts a UNIX timestamp from KuCoin's server into a POSIXct object in UTC, based on the specified time unit.
Usage
time_convert_from_kucoin(time_value, unit = c("ms", "ns", "s"))
Details
Workflow Overview
Input Validation: Ensures
time_value
is numeric, aborting if not.Unit Matching: Validates
unit
against allowed options ("ms"
,"ns"
,"s"
) usingmatch.arg()
.Time Conversion: Converts the timestamp to seconds based on the unit and then to POSIXct using
lubridate::as_datetime()
.
Examples
if (FALSE) { # \dontrun{
# Convert a millisecond timestamp
time_convert_from_kucoin(time_value = 1698777600000, unit = "ms")
# Returns POSIXct equivalent of 2023-10-31 16:00:00 UTC
# Convert a nanosecond timestamp
time_convert_from_kucoin(time_value = 1698777600000000000, unit = "ns")
# Returns POSIXct equivalent of 2023-10-31 16:00:00 UTC
} # }