Mix a date value and a time value. @param IN/OUT ldate Date value. @param ltime Time value. */
| 1436 | @param ltime Time value. |
| 1437 | */ |
| 1438 | void mix_date_and_time(MYSQL_TIME *ldate, const MYSQL_TIME *ltime) |
| 1439 | { |
| 1440 | DBUG_ASSERT(ldate->time_type == MYSQL_TIMESTAMP_DATE || |
| 1441 | ldate->time_type == MYSQL_TIMESTAMP_DATETIME); |
| 1442 | |
| 1443 | if (!ltime->neg && ltime->hour < 24) |
| 1444 | { |
| 1445 | /* |
| 1446 | Simple case: TIME is within normal 24 hours internal. |
| 1447 | Mix DATE part of ltime2 and TIME part of ltime together. |
| 1448 | */ |
| 1449 | ldate->hour= ltime->hour; |
| 1450 | ldate->minute= ltime->minute; |
| 1451 | ldate->second= ltime->second; |
| 1452 | ldate->second_part= ltime->second_part; |
| 1453 | } |
| 1454 | else |
| 1455 | { |
| 1456 | /* Complex case: TIME is negative or outside of 24 hours internal. */ |
| 1457 | longlong seconds; |
| 1458 | long days, useconds; |
| 1459 | int sign= ltime->neg ? 1 : -1; |
| 1460 | ldate->neg= calc_time_diff(ldate, ltime, sign, &seconds, &useconds); |
| 1461 | DBUG_ASSERT(!ldate->neg); |
| 1462 | |
| 1463 | /* |
| 1464 | We pass current date to mix_date_and_time. If we want to use |
| 1465 | this function with arbitrary dates, this code will need |
| 1466 | to cover cases when ltime is negative and "ldate < -ltime". |
| 1467 | */ |
| 1468 | DBUG_ASSERT(ldate->year > 0); |
| 1469 | |
| 1470 | days= (long) (seconds / SECONDS_IN_24H); |
| 1471 | calc_time_from_sec(ldate, seconds % SECONDS_IN_24H, useconds); |
| 1472 | get_date_from_daynr(days, &ldate->year, &ldate->month, &ldate->day); |
| 1473 | } |
| 1474 | ldate->time_type= MYSQL_TIMESTAMP_DATETIME; |
| 1475 | } |
| 1476 | |
| 1477 | |
| 1478 | /** |
nothing calls this directly
no test coverage detected