MCPcopy Create free account
hub / github.com/numpy/numpy / is_holiday

Function is_holiday

numpy/core/src/multiarray/datetime_busday.c:49–72  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

47 * be removed, and the list should be sorted.
48 */
49static int
50is_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

Callers 3

apply_business_day_rollFunction · 0.85
is_business_dayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected