* Returns 1 if the date is a holiday (contained in the sorted * list of dates), 0 otherwise. * * The holidays list should be normalized, which means any NaT (not-a-time) * values, duplicates, and dates already excluded by the weekmask should * be removed, and the list should be sorted. */
| 47 | * be removed, and the list should be sorted. |
| 48 | */ |
| 49 | static int |
| 50 | is_holiday(npy_datetime date, |
| 51 | npy_datetime *holidays_begin, const npy_datetime *holidays_end) |
| 52 | { |
| 53 | npy_datetime *trial; |
| 54 | |
| 55 | /* Simple binary search */ |
| 56 | while (holidays_begin < holidays_end) { |
| 57 | trial = holidays_begin + (holidays_end - holidays_begin) / 2; |
| 58 | |
| 59 | if (date < *trial) { |
| 60 | holidays_end = trial; |
| 61 | } |
| 62 | else if (date > *trial) { |
| 63 | holidays_begin = trial + 1; |
| 64 | } |
| 65 | else { |
| 66 | return 1; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /* Not found */ |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | /* |
| 75 | * Finds the earliest holiday which is on or after 'date'. If 'date' does not |
no outgoing calls
no test coverage detected