{ "info": { "author": "Encode", "author_email": "devs@encodegroup.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Topic :: Software Development :: Libraries" ], "description": "# Time Window\n\nTime Window is a small Python library that implements a representation for a\nperiod of time, in the form of a half-open interval `[since, until)`.\n\n## Installation\n\nInstall using `pip` from PyPI.\n\n```bash\npip install time-window\n```\n\n## Usage\n\nInstantiate a new `TimeWindow` object using two `datetime.datetime` objects for\nthe boundaries.\n```python\n>>> from datetime import datetime\n>>> from time_window import TimeWindow\n\n>>> since = datetime(2019, 1, 23)\n>>> until = datetime(2019, 1, 29)\n\n>>> tw = TimeWindow(since, until)\n>>> tw\nTimeWindow(datetime.datetime(2019, 1, 23, 0, 0), datetime.datetime(2019, 1, 29, 0, 0))\n```\n\nAlternatively, instantiate a new `TimeWindow` object using a `datetime.datetime` object and one\n`datetime.timedelta` for the definition of the boundaries.\n```python\n>>> from datetime import timedelta\n\n>>> delta = timedelta(days=1)\n\n>>> tw = TimeWindow.from_timedelta(since, delta)\n>>> tw\nTimeWindow(datetime.datetime(2019, 1, 23, 0, 0), datetime.datetime(2019, 1, 24, 0, 0))\n```\n\nGet the size of the window.\n```python\n>>> tw.delta\ndatetime.timedelta(1)\n```\n\nGet the time that is in the middle of the window.\n```python\n>>> tw.middle\ndatetime.datetime(2019, 1, 23, 12, 0)\n```\n\nYou can also check if two `TimeWindow` objects overlap.\n```python\n>>> tw = TimeWindow(datetime(2019, 1, 23), datetime(2019, 1, 29))\n>>> tw2 = TimeWindow(datetime(2019, 1, 27), datetime(2019, 1, 30))\n>>> tw.overlaps(tw2)\nTrue\n```\n\nComplementary to the above action, you can check if two time windows are\ncontiguous (i.e., adjacent, sharing one boundary).\n```python\n>>> tw = TimeWindow(datetime(2019, 1, 23), datetime(2019, 1, 29))\n>>> tw2 = TimeWindow(datetime(2019, 1, 20), datetime(2019, 1, 23)\n>>> tw.contiguous(tw2)\n[TimeWindow(datetime.datetime(2019, 1, 20, 0, 0), datetime.datetime(2019, 1, 23, 0, 0)),\n TimeWindow(datetime.datetime(2019, 1, 23, 0, 0), datetime.datetime(2019, 1, 29, 0, 0))]\n\n>>> tw3 = TimeWindow(datetime(2019, 1, 20), datetime(2019, 1, 21))\n>>> tw.contiguous(tw3)\nFalse\n```\n\nAny `TimeWindow` object offers some of the standard [set operations](https://docs.python.org/3.6/library/stdtypes.html#set).\n```python\n>>> tw = TimeWindow(datetime(2019, 1, 23), datetime(2019, 1, 29))\n>>> tw2 = TimeWindow(datetime(2019, 1, 27), datetime(2019, 1, 30))\n\n>>> tw.intersection(tw2)\nTimeWindow(datetime.datetime(2019, 1, 27, 0, 0), datetime.datetime(2019, 1, 29, 0, 0))\n\n>>> tw.union(tw2)\nTimeWindow(datetime.datetime(2019, 1, 23, 0, 0), datetime.datetime(2019, 1, 30, 0, 0))\n\n>>> tw.complement(tw2)\nimeWindow(datetime.datetime(2019, 1, 23, 0, 0), datetime.datetime(2019, 1, 27, 0, 0))\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/EncodeGroup/time-window", "keywords": "time window", "license": "", "maintainer": "", "maintainer_email": "", "name": "time-window", "package_url": "https://pypi.org/project/time-window/", "platform": "", "project_url": "https://pypi.org/project/time-window/", "project_urls": { "Homepage": "https://github.com/EncodeGroup/time-window" }, "release_url": "https://pypi.org/project/time-window/0.0.1/", "requires_dist": [ "babel (<3.0,>=2.1.1)" ], "requires_python": "", "summary": "A Time Window library", "version": "0.0.1" }, "last_serial": 4756800, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "fee62067626b459c372d05306a044ad6", "sha256": "134e9bba7d5449d45e920a214608515521428b4651e4ced8c1d69bf868ceae1e" }, "downloads": -1, "filename": "time_window-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "fee62067626b459c372d05306a044ad6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10269, "upload_time": "2019-01-29T21:30:37", "url": "https://files.pythonhosted.org/packages/01/f7/5e0065d2d944c8010dbaf19a70eba9b51cd889d969bc35cabbc49eb18ac5/time_window-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e64293d784fe4e6001b53a165871f89", "sha256": "7f1ce7b834be237d1a75a7e0fa930f3f4b37069e5525b6d76729cec8748a3b15" }, "downloads": -1, "filename": "time-window-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5e64293d784fe4e6001b53a165871f89", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5599, "upload_time": "2019-01-29T21:30:39", "url": "https://files.pythonhosted.org/packages/82/a8/87ff591fb16b62fe69aa61472e47ce5486626c61cda27f87dab88e7ea30d/time-window-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fee62067626b459c372d05306a044ad6", "sha256": "134e9bba7d5449d45e920a214608515521428b4651e4ced8c1d69bf868ceae1e" }, "downloads": -1, "filename": "time_window-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "fee62067626b459c372d05306a044ad6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10269, "upload_time": "2019-01-29T21:30:37", "url": "https://files.pythonhosted.org/packages/01/f7/5e0065d2d944c8010dbaf19a70eba9b51cd889d969bc35cabbc49eb18ac5/time_window-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e64293d784fe4e6001b53a165871f89", "sha256": "7f1ce7b834be237d1a75a7e0fa930f3f4b37069e5525b6d76729cec8748a3b15" }, "downloads": -1, "filename": "time-window-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5e64293d784fe4e6001b53a165871f89", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5599, "upload_time": "2019-01-29T21:30:39", "url": "https://files.pythonhosted.org/packages/82/a8/87ff591fb16b62fe69aa61472e47ce5486626c61cda27f87dab88e7ea30d/time-window-0.0.1.tar.gz" } ] }