* Returns true if the datetime metadata matches */
| 2972 | * Returns true if the datetime metadata matches |
| 2973 | */ |
| 2974 | NPY_NO_EXPORT npy_bool |
| 2975 | has_equivalent_datetime_metadata(PyArray_Descr *type1, PyArray_Descr *type2) |
| 2976 | { |
| 2977 | PyArray_DatetimeMetaData *meta1, *meta2; |
| 2978 | |
| 2979 | if ((type1->type_num != NPY_DATETIME && |
| 2980 | type1->type_num != NPY_TIMEDELTA) || |
| 2981 | (type2->type_num != NPY_DATETIME && |
| 2982 | type2->type_num != NPY_TIMEDELTA)) { |
| 2983 | return 0; |
| 2984 | } |
| 2985 | |
| 2986 | meta1 = get_datetime_metadata_from_dtype(type1); |
| 2987 | if (meta1 == NULL) { |
| 2988 | PyErr_Clear(); |
| 2989 | return 0; |
| 2990 | } |
| 2991 | meta2 = get_datetime_metadata_from_dtype(type2); |
| 2992 | if (meta2 == NULL) { |
| 2993 | PyErr_Clear(); |
| 2994 | return 0; |
| 2995 | } |
| 2996 | |
| 2997 | /* For generic units, the num is ignored */ |
| 2998 | if (meta1->base == NPY_FR_GENERIC && meta2->base == NPY_FR_GENERIC) { |
| 2999 | return 1; |
| 3000 | } |
| 3001 | |
| 3002 | return meta1->base == meta2->base && |
| 3003 | meta1->num == meta2->num; |
| 3004 | } |
| 3005 | |
| 3006 | /* |
| 3007 | * Casts a single datetime from having src_meta metadata into |
no test coverage detected