SF.net SVN: matplotlib:[8181] branches/v0_99_maint/lib/matplotlib/dates.py
Revision: 8181 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8181&view=rev Author: efiring Date: 2010-03-08 18:09:55 + (Mon, 08 Mar 2010) Log Message: --- dates.py: fix num2jul, jul2num; fixes bug 2963391; thanks to G. Lichtenberg Modified Paths: -- branches/v0_99_maint/lib/matplotlib/dates.py Modified: branches/v0_99_maint/lib/matplotlib/dates.py === --- branches/v0_99_maint/lib/matplotlib/dates.py2010-03-05 23:54:39 UTC (rev 8180) +++ branches/v0_99_maint/lib/matplotlib/dates.py2010-03-08 18:09:55 UTC (rev 8181) @@ -3,8 +3,9 @@ Matplotlib provides sophisticated date plotting capabilities, standing on the shoulders of python :mod:`datetime`, the add-on modules :mod:`pytz` and :mod:`dateutils`. :class:`datetime` objects are -converted to floating point numbers which represent the number of days -since 0001-01-01 UTC. The helper functions :func:`date2num`, +converted to floating point numbers which represent time in days +since 0001-01-01 UTC, plus 1. For example, 0001-01-01, 06:00 is +1.25, not 0.25. The helper functions :func:`date2num`, :func:`num2date` and :func:`drange` are used to facilitate easy conversion to and from :mod:`datetime` and numeric ranges. @@ -225,7 +226,7 @@ *d* is either a :class:`datetime` instance or a sequence of datetimes. Return value is a floating point number (or sequence of floats) -which gives number of days (fraction part represents hours, +which gives one plus the number of days (fraction part represents hours, minutes, seconds) since 0001-01-01 00:00:00 UTC. """ if not cbook.iterable(d): return _to_ordinalf(d) @@ -235,17 +236,18 @@ def julian2num(j): 'Convert a Julian date (or sequence) to a matplotlib date (or sequence).' if cbook.iterable(j): j = np.asarray(j) -return j + 1721425.5 +return j - 1721424.5 def num2julian(n): 'Convert a matplotlib date (or sequence) to a Julian date (or sequence).' if cbook.iterable(n): n = np.asarray(n) -return n - 1721425.5 +return n + 1721424.5 def num2date(x, tz=None): """ -*x* is a float value which gives number of days (fraction part -represents hours, minutes, seconds) since 0001-01-01 00:00:00 UTC. +*x* is a float value which gives one plus the number of days +(fraction part represents hours, minutes, seconds) since +0001-01-01 00:00:00 UTC. Return value is a :class:`datetime` instance in timezone *tz* (default to rcparams TZ value). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- Download IntelĀ® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8182] trunk/matplotlib/lib/matplotlib/dates.py
Revision: 8182 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8182&view=rev Author: efiring Date: 2010-03-08 18:33:04 + (Mon, 08 Mar 2010) Log Message: --- dates.py: fix num2jul, jul2num; fixes bug 2963391; thanks to G. Lichtenberg Modified Paths: -- trunk/matplotlib/lib/matplotlib/dates.py Modified: trunk/matplotlib/lib/matplotlib/dates.py === --- trunk/matplotlib/lib/matplotlib/dates.py2010-03-08 18:09:55 UTC (rev 8181) +++ trunk/matplotlib/lib/matplotlib/dates.py2010-03-08 18:33:04 UTC (rev 8182) @@ -3,8 +3,9 @@ Matplotlib provides sophisticated date plotting capabilities, standing on the shoulders of python :mod:`datetime`, the add-on modules :mod:`pytz` and :mod:`dateutils`. :class:`datetime` objects are -converted to floating point numbers which represent the number of days -since 0001-01-01 UTC. The helper functions :func:`date2num`, +converted to floating point numbers which represent time in days +since 0001-01-01 UTC, plus 1. For example, 0001-01-01, 06:00 is +1.25, not 0.25. The helper functions :func:`date2num`, :func:`num2date` and :func:`drange` are used to facilitate easy conversion to and from :mod:`datetime` and numeric ranges. @@ -225,7 +226,7 @@ *d* is either a :class:`datetime` instance or a sequence of datetimes. Return value is a floating point number (or sequence of floats) -which gives number of days (fraction part represents hours, +which gives one plus the number of days (fraction part represents hours, minutes, seconds) since 0001-01-01 00:00:00 UTC. """ if not cbook.iterable(d): return _to_ordinalf(d) @@ -235,17 +236,18 @@ def julian2num(j): 'Convert a Julian date (or sequence) to a matplotlib date (or sequence).' if cbook.iterable(j): j = np.asarray(j) -return j + 1721425.5 +return j - 1721424.5 def num2julian(n): 'Convert a matplotlib date (or sequence) to a Julian date (or sequence).' if cbook.iterable(n): n = np.asarray(n) -return n - 1721425.5 +return n + 1721424.5 def num2date(x, tz=None): """ -*x* is a float value which gives number of days (fraction part -represents hours, minutes, seconds) since 0001-01-01 00:00:00 UTC. +*x* is a float value which gives one plus the number of days +(fraction part represents hours, minutes, seconds) since +0001-01-01 00:00:00 UTC. Return value is a :class:`datetime` instance in timezone *tz* (default to rcparams TZ value). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- Download IntelĀ® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
