BUG: silent overflow in DateTimeArray subtraction
State: closed

- [x] closes #22492
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Bug
name: Timedelta
description: Timedelta data type

Comments:
Hi @jbrockmendel , thanks for the follow-up. 
- With the suggested change, it now throws `OverflowError: Overflow in int64 addition`. Is this desired behavior? 
- Where should I add the tests? Maybe under `tests/arrays/test_datetimelike.py`?
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22508?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@fa47b8d`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #22508   +/-   ##
=========================================
  Coverage          ?   92.03%           
=========================================
  Files             ?      169           
  Lines             ?    50780           
  Branches          ?        0           
=========================================
  Hits              ?    46737           
  Misses            ?     4043           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.44% <100%> (?)` | |
| #single | `42.25% <100%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22508?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/22508/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `95.52% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22508?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/22508?src=pr&el=footer). Last update [fa47b8d...cfaf42b](https://codecov.io/gh/pandas-dev/pandas/pull/22508?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@shengpu1126 : You should make the changes so that it gets the expected output that you reported in the original issue.  And yes, that does seem like a good place to put the test.  Don't forget a `whatsnew` entry too.
@gfyoung it isn’t that easy.  If you look at the scalar op in the original example, it returns a stdlib timedelta, not a pd.Timedelta.  

@shengpu1126 i think raising overflowerror is correct, will doublecheck.
> it isn’t that easy. If you look at the scalar op in the original example, it returns a stdlib timedelta, not a pd.Timedelta.

@jbrockmendel : Ah, I see.  My response was motivated by the fact that you didn't comment on @shengpu1126 expected output in the original issue, which I took to be a tacit agreement of the expected behavior for patching this bug.
Test will go in tests.arithmetic.test_datetime64
Hello @shengpu1126! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on August 30, 2018 at 15:56 Hours UTC
thanks!