in src/dt.c [550:585]
time_t mktime_tz(const struct tm *tm, const char *tz_name)
{
dt_status_t status = DT_UNKNOWN_ERROR;
dt_timestamp_t t = {0};
dt_representation_t rep = {0};
dt_timezone_t tz = {0,};
time_t result = DT_INVALID_POSIX_TIME;
unsigned long nano = 0;
if (!tm || !result || !tz_name) {
return DT_INVALID_POSIX_TIME;
}
if (dt_timezone_lookup(tz_name, &tz) != DT_OK) {
return DT_INVALID_POSIX_TIME;
}
status = dt_tm_to_representation(tm, 0, &rep);
if (status != DT_OK || dt_validate_representation(&rep) != DT_TRUE) {
dt_timezone_cleanup(&tz);
return DT_INVALID_POSIX_TIME;
}
status = dt_representation_to_timestamp(&rep, &tz, &t, NULL);
dt_timezone_cleanup(&tz);
if (status != DT_OK) {
return DT_INVALID_POSIX_TIME;
}
status = dt_timestamp_to_posix_time(&t, &result, &nano);
if (status != DT_OK) {
return DT_INVALID_POSIX_TIME;
}
return result;
}