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

Function days_to_month_number

numpy/core/src/multiarray/datetime.c:226–246  ·  view source on GitHub ↗

Extracts the month number from a 'datetime64[D]' value */

Source from the content-addressed store, hash-verified

224
225/* Extracts the month number from a 'datetime64[D]' value */
226NPY_NO_EXPORT int
227days_to_month_number(npy_datetime days)
228{
229 npy_int64 year;
230 int *month_lengths, i;
231
232 year = days_to_yearsdays(&days);
233 month_lengths = _days_per_month_table[is_leapyear(year)];
234
235 for (i = 0; i < 12; ++i) {
236 if (days < month_lengths[i]) {
237 return i + 1;
238 }
239 else {
240 days -= month_lengths[i];
241 }
242 }
243
244 /* Should never get here */
245 return 1;
246}
247
248/*
249 * Fills in the year, month, day in 'dts' based on the days

Callers 1

apply_business_day_rollFunction · 0.85

Calls 2

days_to_yearsdaysFunction · 0.85
is_leapyearFunction · 0.85

Tested by

no test coverage detected