Skip to content

Commit

Permalink
Support for local timezone (#118)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bpintea authored Mar 5, 2019
1 parent f6669dd commit 6eda98f
Show file tree
Hide file tree
Showing 16 changed files with 1,090 additions and 474 deletions.
15 changes: 10 additions & 5 deletions driver/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,10 @@ SQLRETURN config_dbc(esodbc_dbc_st *dbc, esodbc_dsn_attrs_st *attrs)
}
INFOH(dbc, "pack JSON: %s.", dbc->pack_json ? "true" : "false");

/* "apply TZ" param for time conversions */
dbc->apply_tz = wstr2bool(&attrs->apply_tz);
INFOH(dbc, "apply TZ: %s.", dbc->apply_tz ? "true" : "false");

/*
* Version checking mode
*/
Expand Down Expand Up @@ -1781,7 +1785,8 @@ static void set_display_size(esodbc_estype_st *es_type)
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
case SQL_TYPE_TIMESTAMP: /* SQL/ES DATE */
es_type->display_size = sizeof(ESODBC_ISO8601_TEMPLATE) - /*0*/1;
es_type->display_size =
ISO8601_TIMESTAMP_LEN(ESODBC_DEF_SEC_PRECISION);
break;


Expand Down Expand Up @@ -1820,7 +1825,7 @@ static void set_display_size(esodbc_estype_st *es_type)
break;
case SQL_INTERVAL_SECOND:
es_type->display_size = ESODBC_MAX_IVL_SECOND_LEAD_PREC + /*.*/1 +
ESODBC_MAX_SEC_PRECISION;
ESODBC_DEF_SEC_PRECISION;
break;
case SQL_INTERVAL_DAY_TO_HOUR:
es_type->display_size = 3 + ESODBC_MAX_IVL_DAY_LEAD_PREC;
Expand All @@ -1830,18 +1835,18 @@ static void set_display_size(esodbc_estype_st *es_type)
break;
case SQL_INTERVAL_DAY_TO_SECOND:
es_type->display_size = 10 + ESODBC_MAX_IVL_DAY_LEAD_PREC +
ESODBC_MAX_SEC_PRECISION;
ESODBC_DEF_SEC_PRECISION;
break;
case SQL_INTERVAL_HOUR_TO_MINUTE:
es_type->display_size = 3 + ESODBC_MAX_IVL_HOUR_LEAD_PREC;
break;
case SQL_INTERVAL_HOUR_TO_SECOND:
es_type->display_size = 7 + ESODBC_MAX_IVL_HOUR_LEAD_PREC +
ESODBC_MAX_SEC_PRECISION;
ESODBC_DEF_SEC_PRECISION;
break;
case SQL_INTERVAL_MINUTE_TO_SECOND:
es_type->display_size = 4 + ESODBC_MAX_IVL_MINUTE_LEAD_PREC +
ESODBC_MAX_SEC_PRECISION;
ESODBC_DEF_SEC_PRECISION;
break;

/*
Expand Down
Loading

0 comments on commit 6eda98f

Please sign in to comment.