in src/unix/dt_unix.c [98:138]
dt_status_t dt_representation_to_timestamp(const dt_representation_t *representation, const dt_timezone_t *timezone,
dt_timestamp_t *first_timestamp, dt_timestamp_t *second_timestamp)
{
struct tm tm = {0,};
time_t posix_time = WRONG_POSIX_TIME;
dt_status_t status = DT_UNKNOWN_ERROR;
if (!representation || !first_timestamp) {
return DT_INVALID_ARGUMENT;
}
if (DT_OK != (status = dt_representation_to_tm(representation, &tm))) {
return status;
}
if (timezone == NULL) {
posix_time = mktime(&tm);
if (posix_time != WRONG_POSIX_TIME) {
first_timestamp->second = posix_time;
first_timestamp->nano_second = representation->nano_second;
return DT_OK;
} else {
return DT_SYSTEM_CALL_ERROR;
}
}
if (timezone != NULL && timezone->state == NULL) {
return DT_INVALID_ARGUMENT;
}
if (WRONG_POSIX_TIME == (posix_time = tz_mktime(timezone->state, &tm))) {
return DT_INVALID_ARGUMENT;
}
first_timestamp->second = posix_time;
first_timestamp->nano_second = representation->nano_second;
return DT_OK;
}