ENH: Change DatetimeIndex.time to also return timezone info
State: closed

- [ ] closes #21358
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Mainly just reverted changes from GH#21281 and updated docs. Also had to change one test added in GH#21281.

Labels:
name: Datetime
description: Datetime data dtype
name: API Design

Comments:
Hello @jquinon! Thanks for updating the PR.





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

##### Comment last updated on July 11, 2018 at 20:57 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21865?src=pr&el=h1) Report
> Merging [#21865](https://codecov.io/gh/pandas-dev/pandas/pull/21865?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5d0daa0522730a6f999ceaf328f63f03dd62d0b4?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #21865      +/-   ##
==========================================
- Coverage   91.92%   91.92%   -0.01%     
==========================================
  Files         160      160              
  Lines       49906    49903       -3     
==========================================
- Hits        45875    45872       -3     
  Misses       4031     4031
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <100%> (-0.01%)` | :arrow_down: |
| #single | `42.11% <0%> (ø)` | :arrow_up: |

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

------

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

does the standard library preserve for ``datetime.datetime.time()`` ?
`.time()` does not but `.timetz()` does:

```
In [12]: pytz.UTC.localize(datetime(2000, 1, 1)).time()
Out[12]: datetime.time(0, 0)

In [13]: pytz.UTC.localize(datetime(2000, 1, 1)).timetz()
Out[13]: datetime.time(0, 0, tzinfo=<UTC>)
```

I guess if we want to follow the standard library naming it should be naive, but I think its useful knowing in which timezone the local time resides.

An alternative is to depreciate the `.time` property for a `time(tz=False)` method that mirrors the standard library, has an option to return tz information and is maybe less API breaking.

Thoughts @jreback? 
hmm its annoying that the std library does this with 2 methods, but I guess can't easily 'remove' a tz from a time (e.g. no ``.tz_localize(None)``.
Yeah that's why I am more inclined to chose the method route to mimic the standard library but at least have a keyword argument (and not a second method) to include the tz in the output or not.  
I can modify or cancel the PR as you guys see fit, just let me know when a decision is made!
I would personally follow the standard library and leave it as is as a naive time. 
You can always get the timezone separately if you want.
@jquinon thanks for working on it anyhow!