{ "info": { "author": "Mark Longair", "author_email": "mark@mysociety.org", "bugtrack_url": null, "classifiers": [], "description": "approx_dates: represent partial or approximate dates in Python\n==============================================================\n\n[This is a preliminary version of this library (hence the 0.*\nversion number) and the API may change.]\n\nIt's frequently useful to be able to represent partial or\napproximate dates in Python. Colloquially, examples of these\nmight be:\n\n* 1963 (i.e. just the year, with no month or day specified)\n* March 1979 (i.e. just the year and the month, with no day\n specified)\n* At some point before the 21st of July 2015\n* At some point after 1st January 2000\n* Some point between 25th and 31st of December 2016\n* At an arbitrary or unknown point in the past\n* At an arbitrary or unknown point in the future\n\nThe ``ApproxDate`` class can represent all of the above, as well\nas precise dates, where the exact year, month and day is known.\n\nThis package has been tested on Python 2.7 and Python 3.5.\n\nSimilar Packages\n~~~~~~~~~~~~~~~~\n\nThe alternative to this package that I'm aware of is the\n``ApproximateDate`` class from `django-date-extensions\n`__. This has\na different model for approximate dates - they can be ``past``,\n``future``, ``YYYY``, ``YYYY-MM`` or ``YYYY-MM-DD``, whereas the\n``ApproxDate`` model in this package can also represent a date\nwhich is known to be between two arbitrary dates, or is known to\nbe before (or after) some particular date.\n\nInstallation\n------------\n\nYou can install this package with:\n\n.. code:: bash\n\n pip install approx_dates\n\nUsage\n-----\n\nYou can create a full date or a partial date from the an ISO\n8601 string:\n\n.. code:: python\n\n from approx_dates.models import ApproxDate\n\n ApproxDate.from_iso8601('1215-06-15')\n ApproxDate.from_iso8601('1215-06')\n ApproxDate.from_iso8601('1215')\n\nOr you can reprent points arbitrarily far in the past or future\nwith:\n\n.. code:: python\n\n ApproxDate.PAST\n ApproxDate.FUTURE\n\nTo represent a date that's somewhere within two bounds, you can\nspecify two endpoints. For example:\n\n.. code:: python\n\n from datetime import date\n\n ApproxDate(date(2016, 12, 25), date(2016, 12, 31))\n\nThese endpoints are intended to be inclusive. For example, the\nabove ``ApproxDate`` might represent the 25th, 26th, ... or the\n31st of December 2016.\n\nYou can test whether an ``ApproxDate`` represents arbitrarily\nfar in the future or in the past with the ``past`` and\n``future`` properties which evaluate to ``True`` or ``False``.\n\nTo convert an ``ApproxDate`` into one of core Python's\n``datetime.date`` objects, you can use on of the following\nmethods:\n\n.. code:: python\n\n ad = ApproxDate.from_iso8601('1979-03')\n\n ad.earliest_date\n >>> datetime.date(1979, 3, 1)\n\n ad.latest_date\n >>> datetime.date(1979, 3, 31)\n\n ad.midpoint_date\n >>> datetime.date(1979, 3, 16)\n\nObviously, whether one ``ApproxDate`` is earlier or later than\nanother is ill-defined, so the ``__lt__``, ``__gt__``,\n``__lte__`` and ``__gte__`` magic methods are not defined on\n``ApproxDate``. If you need to compare two ``ApproxDate``\nobjects, you need to first convert it to a ``datetime.date``\nusing one of the methods above.\n\nThe ``__eq__`` and ``__ne__`` magic methods are defined, so that\ntwo approx dates can be tested for whether they represent\nexactly the same possible range of dates. If the right hand\nside of an equality or inequality comparison is a\n``datetime.date``, it will treated equal if the ``ApproxDate``\non the left is precise to a day, and reprents the same date.\n\nYou can also test whether a ``datetime.date`` might be between\ntwo ``ApproxDate`` or ``datetime.date`` objects using the\n``ApproxDate.possibly_between`` class method, e.g.:\n\n.. code:: python\n\n d1 = ApproxDate.from_iso8601('2000')\n d2 = ApproxDate.from_iso8601('2005')\n ApproxDate.possibly_between(d1, date(2000, 7, 1), d2)\n >>> True\n\n ApproxDate.possibly_between(d1, date(1999, 12, 31), d2)\n >>> True\n\nDevelopment\n-----------\n\nAfter cloning this repository, you can install the dependencies\nfor development with:\n\n.. code:: bash\n\n pip install -e .\n pip install tox\n\nAnd then run the tests with:\n\n.. code:: bash\n\n tox\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "dates", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "approx-dates", "package_url": "https://pypi.org/project/approx-dates/", "platform": "", "project_url": "https://pypi.org/project/approx-dates/", "project_urls": null, "release_url": "https://pypi.org/project/approx-dates/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Classes for representing partial and approximate dates", "version": "0.0.1" }, "last_serial": 2433609, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "b03a46196b093f93aa86c44130b605f1", "sha256": "cc149ce46ca01eac60f58e84cb309939f1067befe60aff13d9c4251eba667bd6" }, "downloads": -1, "filename": "approx_dates-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b03a46196b093f93aa86c44130b605f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5115, "upload_time": "2016-10-31T18:54:29", "url": "https://files.pythonhosted.org/packages/04/a9/822987c21596d17cd1dddb2c14fbbba0d5dbef85e57df22cd6e0ac5dee28/approx_dates-0.0.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "ba7303be13718a8915e42c8c09b6f422", "sha256": "b90f77b56695a8df6ddb852275db0f5884a69047c253ede0e2699c9e189d3003" }, "downloads": -1, "filename": "approx-dates-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ba7303be13718a8915e42c8c09b6f422", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5112, "upload_time": "2016-10-31T18:51:50", "url": "https://files.pythonhosted.org/packages/30/d9/4b533a06c81ac35e6aad0a413129b73104d2b54c9b2d353ea8e1975f031a/approx-dates-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b03a46196b093f93aa86c44130b605f1", "sha256": "cc149ce46ca01eac60f58e84cb309939f1067befe60aff13d9c4251eba667bd6" }, "downloads": -1, "filename": "approx_dates-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b03a46196b093f93aa86c44130b605f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5115, "upload_time": "2016-10-31T18:54:29", "url": "https://files.pythonhosted.org/packages/04/a9/822987c21596d17cd1dddb2c14fbbba0d5dbef85e57df22cd6e0ac5dee28/approx_dates-0.0.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "ba7303be13718a8915e42c8c09b6f422", "sha256": "b90f77b56695a8df6ddb852275db0f5884a69047c253ede0e2699c9e189d3003" }, "downloads": -1, "filename": "approx-dates-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ba7303be13718a8915e42c8c09b6f422", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5112, "upload_time": "2016-10-31T18:51:50", "url": "https://files.pythonhosted.org/packages/30/d9/4b533a06c81ac35e6aad0a413129b73104d2b54c9b2d353ea8e1975f031a/approx-dates-0.0.1.tar.gz" } ] }