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

Function set_datetimestruct_days

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

* Fills in the year, month, day in 'dts' based on the days * offset from 1970. */

Source from the content-addressed store, hash-verified

250 * offset from 1970.
251 */
252static void
253set_datetimestruct_days(npy_int64 days, npy_datetimestruct *dts)
254{
255 int *month_lengths, i;
256
257 dts->year = days_to_yearsdays(&days);
258 month_lengths = _days_per_month_table[is_leapyear(dts->year)];
259
260 for (i = 0; i < 12; ++i) {
261 if (days < month_lengths[i]) {
262 dts->month = i + 1;
263 dts->day = (int)days + 1;
264 return;
265 }
266 else {
267 days -= month_lengths[i];
268 }
269 }
270}
271
272/*
273 * Converts a datetime from a datetimestruct to a datetime based

Callers 1

Calls 2

days_to_yearsdaysFunction · 0.85
is_leapyearFunction · 0.85

Tested by

no test coverage detected