Skip to content

Utility function to convert a Unix timestamp (seconds since 1970-01-01 UTC) into a POSIXct object. Uses lubridate::as_datetime() for readability and consistency with the tidyverse ecosystem.

Usage

whapi_to_posixct(x)

Arguments

x

A numeric or character vector representing a Unix timestamp (seconds since epoch). Can be NULL or NA.

Value

A POSIXct object (in UTC) or NA if x is NULL or NA.

Examples

# Single timestamp
whapi_to_posixct(1756426418)
#> [1] "2025-08-29 00:13:38 UTC"

# Vector of timestamps (with NA)
whapi_to_posixct(c(1756426418, NA))
#> [1] "2025-08-29 00:13:38 UTC" NA                       

# Character input
whapi_to_posixct("1756426418")
#> [1] "2025-08-29 00:13:38 UTC"