Skip to content

Commit 6eda98f

Browse files
authored
Support for local timezone (#118)
* run integration tests with custom driver install - add CLI option to take a connection string and use that to connect to a custom driver installation. * add support for timestamps in local timezone With this commit the driver will be able to use local timestamps towards the application and do the translation between that and ES/SQL (UTC) A connection string parameter controlls if this behavior is enabled; it is disabled by default. The timezone is read from the TZ environment variable, or the system if that isn't set. The driver will now also provide the SQL format of date/timestamp when a DATE/DATETIME value is converted to string. * add the integration tests for the timezone support - the commit also corrects some of the existing tests to respect the column size and/or decimal digits. * fix define conditionals for mktime error message - _WIN64 -> !_USE_32BIT_TIME_T
1 parent f6669dd commit 6eda98f

16 files changed

+1090
-474
lines changed

driver/connect.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,10 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
10921092
}
10931093
INFOH(dbc, "pack JSON: %s.", dbc->pack_json ? "true" : "false");
10941094

1095+
/* "apply TZ" param for time conversions */
1096+
dbc->apply_tz = wstr2bool(&attrs->apply_tz);
1097+
INFOH(dbc, "apply TZ: %s.", dbc->apply_tz ? "true" : "false");
1098+
10951099
/*
10961100
* Version checking mode
10971101
*/
@@ -1781,7 +1785,8 @@ static void set_display_size(esodbc_estype_st *es_type)
17811785
case SQL_TYPE_DATE:
17821786
case SQL_TYPE_TIME:
17831787
case SQL_TYPE_TIMESTAMP: /* SQL/ES DATE */
1784-
es_type->display_size = sizeof(ESODBC_ISO8601_TEMPLATE) - /*0*/1;
1788+
es_type->display_size =
1789+
ISO8601_TIMESTAMP_LEN(ESODBC_DEF_SEC_PRECISION);
17851790
break;
17861791

17871792

@@ -1820,7 +1825,7 @@ static void set_display_size(esodbc_estype_st *es_type)
18201825
break;
18211826
case SQL_INTERVAL_SECOND:
18221827
es_type->display_size = ESODBC_MAX_IVL_SECOND_LEAD_PREC + /*.*/1 +
1823-
ESODBC_MAX_SEC_PRECISION;
1828+
ESODBC_DEF_SEC_PRECISION;
18241829
break;
18251830
case SQL_INTERVAL_DAY_TO_HOUR:
18261831
es_type->display_size = 3 + ESODBC_MAX_IVL_DAY_LEAD_PREC;
@@ -1830,18 +1835,18 @@ static void set_display_size(esodbc_estype_st *es_type)
18301835
break;
18311836
case SQL_INTERVAL_DAY_TO_SECOND:
18321837
es_type->display_size = 10 + ESODBC_MAX_IVL_DAY_LEAD_PREC +
1833-
ESODBC_MAX_SEC_PRECISION;
1838+
ESODBC_DEF_SEC_PRECISION;
18341839
break;
18351840
case SQL_INTERVAL_HOUR_TO_MINUTE:
18361841
es_type->display_size = 3 + ESODBC_MAX_IVL_HOUR_LEAD_PREC;
18371842
break;
18381843
case SQL_INTERVAL_HOUR_TO_SECOND:
18391844
es_type->display_size = 7 + ESODBC_MAX_IVL_HOUR_LEAD_PREC +
1840-
ESODBC_MAX_SEC_PRECISION;
1845+
ESODBC_DEF_SEC_PRECISION;
18411846
break;
18421847
case SQL_INTERVAL_MINUTE_TO_SECOND:
18431848
es_type->display_size = 4 + ESODBC_MAX_IVL_MINUTE_LEAD_PREC +
1844-
ESODBC_MAX_SEC_PRECISION;
1849+
ESODBC_DEF_SEC_PRECISION;
18451850
break;
18461851

18471852
/*

0 commit comments

Comments
 (0)