Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b9ec4c8

Browse files
committed
MNT: deprecate epoch2num/num2epoch
1 parent 99d19f7 commit b9ec4c8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
``epoch2num`` and ``num2epoch`` are deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
These methods convert from unix timestamps to matplotlib floats, but are not
4+
useed internally to matplotlib, and should not be needed by endusers.
5+
To convert a unix timestamp to datetime, simply use
6+
`datetime.datetime.utcfromtimestamp`, or to use numpy datetime64
7+
``dt = np.datetim64(e*1e6, 'us')``.

lib/matplotlib/dates.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,8 @@ def _get_interval(self):
17441744
return self._interval
17451745

17461746

1747+
@_api.deprecated("3.5",
1748+
alternative="mdates.date2num(datetime.utcfromtimestamp(e))")
17471749
def epoch2num(e):
17481750
"""
17491751
Convert UNIX time to days since Matplotlib epoch.
@@ -1765,6 +1767,7 @@ def epoch2num(e):
17651767
return (dt + np.asarray(e)) / SEC_PER_DAY
17661768

17671769

1770+
@_api.deprecated("3.5", alternative="mdates.num2date(e).timestamp()")
17681771
def num2epoch(d):
17691772
"""
17701773
Convert days since Matplotlib epoch to UNIX time.

0 commit comments

Comments
 (0)