Follow-Up: Unify apply and onOffset implementations
State: closed

This follows up on #18280, #18278, and #18263.

`get_day_of_month` is extended to handle `business_start` and `business_end` in addition to `start` and `end`.

`_day_opt` attributes are added to YearFoo, QuarterFoo, and MonthFoo offsets.  After some more algebraic simplification (done in a separate PR), their apply and onOffset methods will become identical and can be implemented in the base Year, Quarter, and Month classes.

I expect a small performance penalty from calling `self._get_offset_day` in cases where could hard-code `1`, but the benefits of a unified+simplified implementation outweigh that.


Labels:
name: Frequency
description: DateOffsets
name: Clean

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=h1) Report
> Merging [#18329](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/a26b6767516dbbb89de3229ee65a3cb40ab497eb?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18329/graphs/tree.svg?width=650&src=pr&token=eZ4WkYLtcO&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18329      +/-   ##
==========================================
- Coverage   91.38%   91.36%   -0.02%     
==========================================
  Files         164      164              
  Lines       49780    49786       +6     
==========================================
- Hits        45491    45488       -3     
- Misses       4289     4298       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.16% <100%> (ø)` | :arrow_up: |
| #single | `39.52% <24.56%> (-0.04%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `96.92% <100%> (+0.01%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=footer). Last update [a26b676...30991ba](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=h1) Report
> Merging [#18329](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/f724066f4b3e8b402f7307a132b0d9c5e89ab60f?src=pr&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18329/graphs/tree.svg?token=eZ4WkYLtcO&src=pr&height=150&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #18329      +/-   ##
==========================================
- Coverage   91.38%   91.34%   -0.05%     
==========================================
  Files         164      164              
  Lines       49790    49796       +6     
==========================================
- Hits        45501    45486      -15     
- Misses       4289     4310      +21
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.14% <100%> (-0.03%)` | :arrow_down: |
| #single | `39.55% <27.11%> (-0.04%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/tseries/offsets.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvb2Zmc2V0cy5weQ==) | `96.92% <100%> (+0.01%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `63.44% <0%> (-1.82%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.8% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=footer). Last update [f724066...1f3c76e](https://codecov.io/gh/pandas-dev/pandas/pull/18329?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Appveyor error looks like floating point error in an unrelated test. Will push dummy commit in a bit.
can you rebase
looks fine. can you run the offset asvs & report 

> I expect a small performance penalty

is? 
Pretty tame by local standards:

```
taskset 7 asv continuous -f 1.1 -E virtualenv master HEAD -b timeseries -b period
[...]
     [6405919e]       [1f3c76e9]
+        1.67±0ms      1.95±0.09ms     1.17  timeseries.DatetimeIndex.time_add_offset_delta
+      70.4±0.4μs         80.2±2μs     1.14  period.Properties.time_start_time
+     14.9±0.04ms       16.9±0.2ms     1.14  timeseries.Iteration.time_iter_periodindex_preexit
+       128±0.5μs        141±0.4μs     1.10  timeseries.Offsets.time_custom_bmonthbegin_incr_n
-         817±1ns          737±4ns     0.90  period.Properties.time_year
-      27.9±0.2μs       25.0±0.3μs     0.90  timeseries.Offsets.time_custom_bday_cal_incr
-     1.59±0.09ms      1.40±0.04ms     0.88  timeseries.ToDatetime.time_cache_false_with_dup_string_dates_and_format
-      21.9±0.3μs      19.0±0.04μs     0.87  timeseries.Offsets.time_timeseries_day_incr
-      21.8±0.1μs      18.5±0.08μs     0.85  timeseries.Offsets.time_custom_bday_incr
-        876±20ns        733±0.7ns     0.84  period.Properties.time_hour
-           16.6s            13.9s     0.83  gil.nogil_datetime_fields.time_datetime_to_period
-      14.5±0.4μs      12.0±0.04μs     0.83  timeseries.SemiMonthOffset.time_begin_apply

taskset 7 asv continuous -f 1.1 -E virtualenv master HEAD -b timeseries -b period
[...]
       before           after         ratio
     [6405919e]       [1f3c76e9]
+        6.79±0μs      7.79±0.01μs     1.15  timeseries.DatetimeIndex.time_timestamp_tzinfo_cons
+      6.51±0.1ms       7.34±0.1ms     1.13  timeseries.DatetimeIndex.time_dti_factorize
-     20.9±0.08μs      18.8±0.09μs     0.90  timeseries.Offsets.time_custom_bday_incr
-        844±10ns          752±5ns     0.89  period.Properties.time_week
-        79.6±2ms       70.8±0.2ms     0.89  timeseries.ToDatetime.time_cache_false_with_dup_string_tzoffset_dates
-        858±20ns          735±3ns     0.86  period.Properties.time_day
-      33.2±0.7μs      27.3±0.07μs     0.82  timeseries.Offsets.time_custom_bday_decr
-           46.6s            37.7s     0.81  gil.nogil_datetime_fields.time_period_to_datetime
```
One more:

```
     before           after         ratio
     [6405919e]       [1f3c76e9]
+        748±10ns          870±3ns     1.16  period.PeriodProperties.time_month
+      7.26±0.2ms       8.36±0.2ms     1.15  timeseries.DatetimeIndex.time_dti_tz_factorize
-         824±5ns          738±6ns     0.90  period.Properties.time_month
-         117±3μs        104±0.1μs     0.89  timeseries.Offsets.time_custom_bmonthend_decr_n
-        18.2±1μs      16.2±0.04μs     0.89  timeseries.SemiMonthOffset.time_end_incr
-     7.76±0.05μs      6.86±0.02μs     0.88  timeseries.DatetimeIndex.time_timestamp_tzinfo_cons
-         156±4ms          138±2ms     0.88  timeseries.ToDatetime.time_iso8601_tz_spaceformat
-      20.9±0.4μs       18.1±0.1μs     0.86  timeseries.Offsets.time_custom_bday_incr
-      33.2±0.6μs       27.8±0.2μs     0.84  timeseries.Offsets.time_custom_bday_decr
```
thanks!