| 2285 | |
| 2286 | |
| 2287 | static void datetime_to_text(const dsc* from, dsc* to, Callbacks* cb) |
| 2288 | { |
| 2289 | /************************************** |
| 2290 | * |
| 2291 | * d a t e t i m e _ t o _ t e x t |
| 2292 | * |
| 2293 | ************************************** |
| 2294 | * |
| 2295 | * Functional description |
| 2296 | * Convert a timestamp, date or time value to text. |
| 2297 | * |
| 2298 | **************************************/ |
| 2299 | bool version4 = true; |
| 2300 | |
| 2301 | fb_assert(DTYPE_IS_TEXT(to->dsc_dtype)); |
| 2302 | |
| 2303 | // Convert a date or time value into a timestamp for manipulation |
| 2304 | |
| 2305 | bool tzLookup = true; |
| 2306 | tm times; |
| 2307 | memset(×, 0, sizeof(struct tm)); |
| 2308 | |
| 2309 | int fractions = 0; |
| 2310 | USHORT timezone; |
| 2311 | |
| 2312 | switch (from->dsc_dtype) |
| 2313 | { |
| 2314 | case dtype_sql_time: |
| 2315 | Firebird::TimeStamp::decode_time(*(GDS_TIME*) from->dsc_address, |
| 2316 | ×.tm_hour, ×.tm_min, ×.tm_sec, &fractions); |
| 2317 | break; |
| 2318 | |
| 2319 | case dtype_sql_time_tz: |
| 2320 | case dtype_ex_time_tz: |
| 2321 | tzLookup = TimeZoneUtil::decodeTime(*(ISC_TIME_TZ*) from->dsc_address, |
| 2322 | true, TimeZoneUtil::NO_OFFSET, ×, &fractions); |
| 2323 | timezone = ((ISC_TIME_TZ*) from->dsc_address)->time_zone; |
| 2324 | break; |
| 2325 | |
| 2326 | case dtype_sql_date: |
| 2327 | Firebird::TimeStamp::decode_date(*(GDS_DATE *) from->dsc_address, ×); |
| 2328 | break; |
| 2329 | |
| 2330 | case dtype_timestamp: |
| 2331 | cb->isVersion4(version4); // Used in the conversion to text some lines below. |
| 2332 | Firebird::TimeStamp::decode_timestamp(*(GDS_TIMESTAMP*) from->dsc_address, ×, &fractions); |
| 2333 | break; |
| 2334 | |
| 2335 | case dtype_timestamp_tz: |
| 2336 | case dtype_ex_timestamp_tz: |
| 2337 | cb->isVersion4(version4); // Used in the conversion to text some lines below. |
| 2338 | tzLookup = TimeZoneUtil::decodeTimeStamp(*(ISC_TIMESTAMP_TZ*) from->dsc_address, |
| 2339 | true, TimeZoneUtil::NO_OFFSET, ×, &fractions); |
| 2340 | timezone = ((ISC_TIMESTAMP_TZ*) from->dsc_address)->time_zone; |
| 2341 | break; |
| 2342 | |
| 2343 | default: |
| 2344 | fb_assert(false); |
no test coverage detected