Repository: sunpy/sunpy

Issue:
Document t in TimeRange
`TimeRange` had a `.__contains__` method, but this isn't well documented. We should add some more obvious documentation that one can do `t in TimeRange`.


Discussion:
you can to `t in TimeRange()` because it has a [`__contains__`](https://github.com/sunpy/sunpy/blob/master/sunpy/time/timerange.py#L404)
Maybe it needs to be better documented?
Maybe, I was looking at the API here: https://docs.sunpy.org/en/stable/api/sunpy.time.TimeRange.html#sunpy.time.TimeRange - perhaps there's a way to include `__contains__` in the listing.
What if we renamed it to `contains` and see if it shows up in the docs? 
That would work, but we should keep `__contains__` so `t in TimeRange` still works.
Then could  we keep `__contains__`, then have `contains` call that and copy the doc string from it?
Hi, is this issue still open? If yes, can someone guide me on what exactly is the issue?
Hi, this issue is still open ! I would say adding a `Notes` section to the docstring, that says it is possible to do `t in timerange` would be a good way to document this.
What about an example as well?
I checked the documentation of the `_contains_` function within class `TimeRange`. I notice it already contains a docstring along with example suggesting that `t in timerange` is possible.
Doesn't that solve the issue? Or have I interpreted the issue incorrectly?
What documentation? I can't find any on this page: https://docs.sunpy.org/en/stable/api/sunpy.time.TimeRange.html#sunpy.time.TimeRange 
https://github.com/sunpy/sunpy/blob/1.1/sunpy/time/timerange.py#L404 I guess because its `__contains__` its not showing up in docs?
Yeah I was referring to the code documentation posted by @hayesla . Is there a way I can edit https://docs.sunpy.org/en/stable/api/sunpy.time.TimeRange.html#sunpy.time.TimeRange to display a similar description under the methods table?
I'm not too sure? and I don't think we want to rename it to `contains`.

One way to do this is to put it in the `Notes` section in the class description ([here](https://github.com/sunpy/sunpy/blob/1.1/sunpy/time/timerange.py#L20)) with an example that `time1 in time_range` will return a boolean answer and then maybe an example there. That should then show up in the docs under the example section. 

Is that what you had in mind @dstansby ? 
Why did this get closed? I don't think some `t in timerange` documentation has been added to the docstring.

Resolving patch:
diff --git a/sunpy/time/timerange.py b/sunpy/time/timerange.py
--- a/sunpy/time/timerange.py
+++ b/sunpy/time/timerange.py
@@ -26,6 +26,10 @@ class TimeRange:
        Regardless of how a `sunpy.time.TimeRange` is constructed it will always
        provide a positive time range where the start time is before the end time.
 
+       `~sunpy.time.TimeRange.__contains__` has been implemented which means you can
+       check if a time is within the time range you have created.
+       Please see the example section below.
+
     Parameters
     ----------
     a : {parse_time_types}
@@ -54,6 +58,13 @@ class TimeRange:
                576000.0 minutes or
                34560000.0 seconds
     <BLANKLINE>
+    >>> time1 = '2014/5/5 12:11'
+    >>> time2 = '2012/5/5 12:11'
+    >>> time_range = TimeRange('2014/05/04 13:54', '2018/02/03 12:12')
+    >>> time1 in time_range
+    True
+    >>> time2 in time_range
+    False
     """
 
     def __init__(self, a, b=None, format=None):


Test patch: