static moment_t THX_moment_with_day_of_year(pTHX_ const moment_t *mt, IV v) { int y; dt_to_yd(moment_local_dt(mt), &y, NULL); if (v < 1 || v > 365) { int diy = dt_days_in_year(y); if (v < 1 || v > diy) croak("Parameter 'day' is out of the range [1, %d]", diy); } return THX_moment_with_local_dt(aTHX_ mt, dt_from_yd(y, (int)v)); }
int dt_length_of_year(dt_t dt) { int y; dt_to_yd(dt, &y, NULL); return dt_days_in_year(y); }
dt_t dt_end_of_year(dt_t dt, int offset) { int y; dt_to_yd(dt, &y, NULL); return dt_from_yd(y + offset + 1, 0); }
dt_t dt_start_of_year(dt_t dt, int offset) { int y; dt_to_yd(dt, &y, NULL); return dt_from_yd(y + offset, 1); }