| 4317 | |
| 4318 | |
| 4319 | dsc* evlFirstLastDay(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, |
| 4320 | impure_value* impure) |
| 4321 | { |
| 4322 | fb_assert(args.getCount() >= 2); |
| 4323 | |
| 4324 | Request* request = tdbb->getRequest(); |
| 4325 | |
| 4326 | const dsc* partDsc = EVL_expr(tdbb, request, args[0]); |
| 4327 | if (request->req_flags & req_null) // return NULL if partDsc is NULL |
| 4328 | return NULL; |
| 4329 | |
| 4330 | const dsc* valueDsc = EVL_expr(tdbb, request, args[1]); |
| 4331 | if (request->req_flags & req_null) // return NULL if valueDsc is NULL |
| 4332 | return NULL; |
| 4333 | |
| 4334 | TimeStamp timestamp; |
| 4335 | tm times = {0}; |
| 4336 | int fractions = 0; |
| 4337 | |
| 4338 | switch (valueDsc->dsc_dtype) |
| 4339 | { |
| 4340 | case dtype_sql_date: |
| 4341 | timestamp.value().timestamp_date = *(GDS_DATE*) valueDsc->dsc_address; |
| 4342 | timestamp.value().timestamp_time = 0; |
| 4343 | timestamp.decode(×, &fractions); |
| 4344 | break; |
| 4345 | |
| 4346 | case dtype_timestamp: |
| 4347 | timestamp.value() = *(GDS_TIMESTAMP*) valueDsc->dsc_address; |
| 4348 | timestamp.decode(×, &fractions); |
| 4349 | break; |
| 4350 | |
| 4351 | case dtype_timestamp_tz: |
| 4352 | TimeZoneUtil::decodeTimeStamp(*(ISC_TIMESTAMP_TZ*) valueDsc->dsc_address, false, TimeZoneUtil::NO_OFFSET, |
| 4353 | ×, &fractions); |
| 4354 | break; |
| 4355 | |
| 4356 | default: |
| 4357 | status_exception::raise( |
| 4358 | Arg::Gds(isc_expression_eval_err) << |
| 4359 | Arg::Gds(isc_sysf_invalid_date_timestamp) << |
| 4360 | Arg::Str(function->name)); |
| 4361 | break; |
| 4362 | } |
| 4363 | |
| 4364 | const SLONG part = MOV_get_long(tdbb, partDsc, 0); |
| 4365 | |
| 4366 | switch (part) |
| 4367 | { |
| 4368 | case blr_extract_year: |
| 4369 | times.tm_mon = 0; |
| 4370 | // fall through |
| 4371 | |
| 4372 | case blr_extract_month: |
| 4373 | times.tm_mday = 1; |
| 4374 | break; |
| 4375 | |
| 4376 | case blr_extract_quarter: |
nothing calls this directly
no test coverage detected