in src/unix/dt_unix.c [71:96]
dt_status_t dt_timestamp_to_representation(const dt_timestamp_t *timestamp, const dt_timezone_t *tz, dt_representation_t *representation)
{
struct tm tm = {0,};
if (timestamp == NULL || representation == NULL) {
return DT_INVALID_ARGUMENT;
}
if (tz == NULL) {
if (localtime_r(&(timestamp->second), &tm) == NULL) {
return DT_SYSTEM_CALL_ERROR;
}
return dt_tm_to_representation(&tm, timestamp->nano_second, representation);
}
if (tz != NULL && tz->state == NULL) {
return DT_INVALID_ARGUMENT;
}
if (tz_localtime_r(tz->state, &(timestamp->second), &tm) == NULL) {
return DT_INVALID_ARGUMENT;
}
return dt_tm_to_representation(&tm, timestamp->nano_second, representation);
}