* This provides the casting rules for the DATETIME data type metadata. */
| 1387 | * This provides the casting rules for the DATETIME data type metadata. |
| 1388 | */ |
| 1389 | NPY_NO_EXPORT npy_bool |
| 1390 | can_cast_datetime64_metadata(PyArray_DatetimeMetaData *src_meta, |
| 1391 | PyArray_DatetimeMetaData *dst_meta, |
| 1392 | NPY_CASTING casting) |
| 1393 | { |
| 1394 | switch (casting) { |
| 1395 | case NPY_UNSAFE_CASTING: |
| 1396 | return 1; |
| 1397 | |
| 1398 | case NPY_SAME_KIND_CASTING: |
| 1399 | return can_cast_datetime64_units(src_meta->base, dst_meta->base, |
| 1400 | casting); |
| 1401 | |
| 1402 | case NPY_SAFE_CASTING: |
| 1403 | return can_cast_datetime64_units(src_meta->base, dst_meta->base, |
| 1404 | casting) && |
| 1405 | datetime_metadata_divides(src_meta, dst_meta, 0); |
| 1406 | |
| 1407 | default: |
| 1408 | return src_meta->base == dst_meta->base && |
| 1409 | src_meta->num == dst_meta->num; |
| 1410 | } |
| 1411 | } |
| 1412 | |
| 1413 | /* |
| 1414 | * This provides the casting rules for the TIMEDELTA data type metadata. |
no test coverage detected