Skip to contents

Converts an R POSIXct/POSIXt (or anything as.POSIXlt() accepts) into a timezone-explicit Python datetime in UTC. A value that is already a Python datetime is returned unchanged.

Usage

ts2pydatetime(x)

Arguments

x

An R time, or an existing Python datetime.datetime.

Value

A Python datetime.datetime with tzinfo set to UTC.

Details

The timezone is made explicit (UTC) on the Python side so that downstream code does not silently reinterpret a naive datetime in the local zone.

Examples

if (FALSE) { # \dontrun{
ts2pydatetime(Sys.time())
} # }