{ "info": { "author": "Marcos Sanchez", "author_email": "marsanben92@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "This package allows you to store complex relative dates in string tokens.\n\n- **To define the initial/starting point in time** (typically written as `now`), to\n work with dates in the past or in the future. Ideal to perform date\n simulations.\n- **Time zone configuration**. Additionally to the starting point in time, TZs\n can be provided to as to somehow abstract the user away from localizing\n *datetimes* objects in their apps.\n\n As a disclaimer, if the custom datetime specified as the starting point\n (`now`'s value) is tz-unaware or naive, it will be treated as an UTC one.\n Default `now`'s value also fallsback to `datetime.datetime.utcnow`, localized\n to UTC.\n\n Now, if a time zone is specified, the ``now``'s value will be coerced to that\n TZ prior to applying both snap and modifier expressions. This is handy\n to quickly resolve tokens given any point in time (either naive or aware), a\n time zone and the datetoken itself.\n\n============\nMotivation\n============\nHave you ever needed to make an application where dates needed to be\nrepresented in a relative fashion, like background periodic\ntasks, datetime range pickers... in a compact and stringified format? This\nlibrary enables you to persist these string tokens during the lifetime of a\nprocess or even longer, since calculations are performed in the moment of\nevaluation. Theses tokens are also useful when caching URLs as replacement\nof timestamps, which would break caching given their mutability nature.\n\nSome common examples of relative tokens:\n\n- Today: ``now/d``, ``now``\n- Yesterday: ``now-d/d``, ``now-d@d``\n- Last 24 hours: ``now-1d``, ``now``. Also writable as: ``now-24h``,\n ``now``\n- Last business week: ``now-w/bw``, ``now-w@bw``\n- This business week: ``now/bw``, ``now@bw``\n- Last month: ``now-1M/M``, ``now-1M@M``\n- Last month first business week: ``now-M/M+w/bw``, ``now-M/M+w@bw``\n\nAs you may have noticed, token follow a pattern:\n\n- The word ``now``. It means the point in the future timeline when\n tokens are parsed to their datetime form.\n- Optionally, modifiers to add and/or subtract the future value of\n ``now`` can be used. Unsurprisingly, additions are set via ``+``, while\n ``-`` mean subtractions. These modifiers can be chained as many times\n as needed. E.g: ``now-1M+3d+2h``. Along with the arithmetical sign\n and the amount, the unit of time the amount refers to must be\n specified. Currently, the supported units are:\n\n - ``s`` seconds\n - ``m`` minutes\n - ``h`` hours\n - ``d`` days\n - ``w`` weeks\n - ``M`` months\n\n- Optionally, there exist two extra modifiers to snap dates to the\n start or the end of any given snapshot unit. Those are:\n\n - ``/`` Snap the date to the start of the snapshot unit.\n - ``@`` Snap the date to the end of the snapshot unit.\n\n Snapshot units are the same as arithmetical modifiers, plus ``bw``,\n meaning *business week*. With this, we achieve a simple way to define\n canonical relative date ranges, such as *Today* or *Last month*. As\n an example of the later:\n\n - String representation: ``now-1M/M``, ``now-1M@M``\n - Being today *15 Jan 2018*, the result range should be: *2018-01-01\n 00:00:00 / 2018-01-31 23:59:59*\n\n\nInstalling\n----------\n\nInstall and update via either `pipenv`_ or `pip`_\n\n.. code:: shell\n\n pipenv install datetoken\n\nor\n\n.. code:: shell\n\n pip install datetoken\n\n\nExamples and usage\n------------------\n\nMost probably you will be dealing with simple presets such as\n*yesterday* or the *last 24 hours*.\n\n.. code:: python\n\n >>> from datetoken.utils import token_to_date\n >>> from datetime import datetime\n >>> print(datetime.utcnow())\n 2018-10-18 14:08:47\n >>> token_to_date('now-d/d') # Start of yesterday\n 2018-10-17 00:00:00\n >>> token_to_date('now-d@d') # End of yesterday\n 2018-10-17 23:59:59\n\nFor more details, refer to `README`_.\n\n.. _readme: https://github.com/sonirico/datetoken#datetoken--\n.. _pipenv: https://pipenv.readthedocs.io/en/latest/\n.. _pip: https://pip.pypa.io/en/stable/quickstart/\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://pypi.org/project/datetoken/", "keywords": "", "license": "MIT", "maintainer": "Marcos Sanchez", "maintainer_email": "marsanben92@gmail.com", "name": "datetoken", "package_url": "https://pypi.org/project/datetoken/", "platform": "any", "project_url": "https://pypi.org/project/datetoken/", "project_urls": { "Code": "https://github.com/sonirico/datetoken/", "Homepage": "https://pypi.org/project/datetoken/", "Issue tracker": "https://github.com/sonirico/datetoken/issues" }, "release_url": "https://pypi.org/project/datetoken/0.3.2/", "requires_dist": [ "pytz (<2019.3,>=2018.04)", "python-dateutil (<2.8.1,>=2.7.3)", "pytest (>=3) ; extra == 'dev'", "freezegun (==0.3.12) ; extra == 'dev'", "coverage ; extra == 'dev'", "tox ; extra == 'dev'" ], "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "summary": "Convert relative string tokens into datetime objects", "version": "0.3.2" }, "last_serial": 5934425, "releases": { "0.1.0b0": [ { "comment_text": "", "digests": { "md5": "885e07529b889fb71a83def3adad68c1", "sha256": "d0119fbc63afbcf999e511cfe7dc44a149c3579643c377f5f7b4194c3ff4573d" }, "downloads": -1, "filename": "datetoken-0.1.0b0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "885e07529b889fb71a83def3adad68c1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7995, "upload_time": "2018-10-19T11:56:21", "url": "https://files.pythonhosted.org/packages/39/ff/03ef06725588cb284b5832782cdfab89caed39b8d53a8a3a9f99e6213530/datetoken-0.1.0b0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d0ddfef6cdef152ed6f01da0b97c2ef", "sha256": "56e89ed445b65ffb2557782dbc9e01665d19c010e616825d018c2e65f0e17515" }, "downloads": -1, "filename": "datetoken-0.1.0b0.tar.gz", "has_sig": false, "md5_digest": "2d0ddfef6cdef152ed6f01da0b97c2ef", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7275, "upload_time": "2018-10-19T11:56:22", "url": "https://files.pythonhosted.org/packages/33/f8/237683f8cc6a9fb840ded268d38a63551a6ce7f77d4b20de8d6db36ec2f2/datetoken-0.1.0b0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "cb26abf27fb5c41fd34b760e6d2b32da", "sha256": "a11e5eaf86939b5b6572f1f8f88d95ba7374c8bc468ed70caf740b97dd0fdc21" }, "downloads": -1, "filename": "datetoken-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "cb26abf27fb5c41fd34b760e6d2b32da", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7874, "upload_time": "2018-10-19T12:03:11", "url": "https://files.pythonhosted.org/packages/2a/8e/9da1ee140220808688fe740b7b84d8032041db8fbaabcc79c44257851716/datetoken-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "33c83ea9e51dec98013368f0c879bc2d", "sha256": "906422d3c68de1e9e2d211bdca420a3f16186563cf889a9fdc4e7fd1203754a8" }, "downloads": -1, "filename": "datetoken-0.1.1.tar.gz", "has_sig": false, "md5_digest": "33c83ea9e51dec98013368f0c879bc2d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7219, "upload_time": "2018-10-19T12:03:13", "url": "https://files.pythonhosted.org/packages/2b/61/ee05883a704e3c2203bf29d1eb337fec5fe73bfcb8e8623b76ff2fc46574/datetoken-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "75b5c1868f2ccdff1010f957a796c281", "sha256": "9458222473bcaae7842f0dc1c9fd0ea40178db658a419241f5797a1821bf6e1c" }, "downloads": -1, "filename": "datetoken-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "75b5c1868f2ccdff1010f957a796c281", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7882, "upload_time": "2018-11-29T12:10:13", "url": "https://files.pythonhosted.org/packages/94/20/21601343d34c2d4c742830b057bcc073585963198e17dd8178fc19d60b79/datetoken-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7d9dcef9491a86ce939b75a201f32c0c", "sha256": "8894e507a2efe1cf55f43d14e48ec16f38401a5960c9c4a729255059ad74acf6" }, "downloads": -1, "filename": "datetoken-0.1.2.tar.gz", "has_sig": false, "md5_digest": "7d9dcef9491a86ce939b75a201f32c0c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7333, "upload_time": "2018-11-29T12:10:15", "url": "https://files.pythonhosted.org/packages/dc/65/e73ffdd959d7e38bedcc51006231e92053b028d1d0c0b77a33d1a5c6cc8f/datetoken-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "185620b7b237479f4607cd6371c35364", "sha256": "9204ce2b0704bc39137c465700478574bdc73d122bba9cb6979f899cc9405068" }, "downloads": -1, "filename": "datetoken-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "185620b7b237479f4607cd6371c35364", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9015, "upload_time": "2019-01-14T14:38:44", "url": "https://files.pythonhosted.org/packages/85/60/ee8dcca6f6c37b3410053dd317955489f1e8116e84cffe4621ac544090eb/datetoken-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "524e67e64e1fb6d536f020484cd45bb0", "sha256": "4190ef80138b4f963d9e63008ffda33124758474fc91b383e0d97fad87428a37" }, "downloads": -1, "filename": "datetoken-0.2.0.tar.gz", "has_sig": false, "md5_digest": "524e67e64e1fb6d536f020484cd45bb0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 7123, "upload_time": "2019-01-14T14:38:45", "url": "https://files.pythonhosted.org/packages/a0/a8/5bc1938ef164af70c1360f75230c93520e40d282418050bbaeeea8b0edb0/datetoken-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "8e67ffe2c36ebc61bc0e0f48d8c597b9", "sha256": "90629089c4c8b519de05ca8874aeaf3fb0cb9eab8b065935c2cd9a6c220d2b5b" }, "downloads": -1, "filename": "datetoken-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e67ffe2c36ebc61bc0e0f48d8c597b9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 12025, "upload_time": "2019-03-01T07:26:59", "url": "https://files.pythonhosted.org/packages/87/ce/fe6cc40420f6cb3e38e317fcbe87f31fcc673f4e629b4259ccff60285842/datetoken-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1385a6547c7f76427d3f01f4a2d7db8b", "sha256": "8b7c60e2b00f3f360306733fb26c6e3af484fb8c9be0ca49d5c1b312956b00a5" }, "downloads": -1, "filename": "datetoken-0.3.0.tar.gz", "has_sig": false, "md5_digest": "1385a6547c7f76427d3f01f4a2d7db8b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9740, "upload_time": "2019-03-01T07:27:01", "url": "https://files.pythonhosted.org/packages/11/d4/feeb82ac6f0698a93dfbbbd7aa21d27f9a15d4b64b12543caa9e94dd62fa/datetoken-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "3eb1d81af370172f59f4944b31cde3dc", "sha256": "f05e5e4857517e7ce04fef8a4f30d373efd8a814f683d116624f51024ae53835" }, "downloads": -1, "filename": "datetoken-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3eb1d81af370172f59f4944b31cde3dc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 12103, "upload_time": "2019-03-01T08:49:35", "url": "https://files.pythonhosted.org/packages/bc/32/431729dc03099e258243040ade6f036f498155159354caf57f38a8a1f80e/datetoken-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e2efabad53da606d596338c2d47e8cbe", "sha256": "c2d24382473ab8e21ec09fa736ff942fe1bda295259028d8161015edcdaaa438" }, "downloads": -1, "filename": "datetoken-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e2efabad53da606d596338c2d47e8cbe", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9799, "upload_time": "2019-03-01T08:49:37", "url": "https://files.pythonhosted.org/packages/27/8a/8501f21463b17fc94431e99a573a72c459a1d8007cc6a0c601f429d1cfcd/datetoken-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "30a5a91fa064fc2e24fbc4580f790ef7", "sha256": "936b33881136a17e2f3a3d464f4a8e8e639aa6746ce7329784d92ef91b8d0774" }, "downloads": -1, "filename": "datetoken-0.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "30a5a91fa064fc2e24fbc4580f790ef7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9972, "upload_time": "2019-10-06T10:16:48", "url": "https://files.pythonhosted.org/packages/32/17/244f99c48881ac998b9a2730e016722180bf0d39aa3ef7b245e0cd711090/datetoken-0.3.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "599a174d8911ffd488a519b8315b7a22", "sha256": "a524d5ced33bc1932536c4daedd79b803faf92fda2b778b38aee83bc3ac33444" }, "downloads": -1, "filename": "datetoken-0.3.2.tar.gz", "has_sig": false, "md5_digest": "599a174d8911ffd488a519b8315b7a22", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9061, "upload_time": "2019-10-06T10:16:50", "url": "https://files.pythonhosted.org/packages/ba/8b/676e754a7d58489d63f060cb14bdb585081554f511fdeb4c279bfdec0b4e/datetoken-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "30a5a91fa064fc2e24fbc4580f790ef7", "sha256": "936b33881136a17e2f3a3d464f4a8e8e639aa6746ce7329784d92ef91b8d0774" }, "downloads": -1, "filename": "datetoken-0.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "30a5a91fa064fc2e24fbc4580f790ef7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9972, "upload_time": "2019-10-06T10:16:48", "url": "https://files.pythonhosted.org/packages/32/17/244f99c48881ac998b9a2730e016722180bf0d39aa3ef7b245e0cd711090/datetoken-0.3.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "599a174d8911ffd488a519b8315b7a22", "sha256": "a524d5ced33bc1932536c4daedd79b803faf92fda2b778b38aee83bc3ac33444" }, "downloads": -1, "filename": "datetoken-0.3.2.tar.gz", "has_sig": false, "md5_digest": "599a174d8911ffd488a519b8315b7a22", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 9061, "upload_time": "2019-10-06T10:16:50", "url": "https://files.pythonhosted.org/packages/ba/8b/676e754a7d58489d63f060cb14bdb585081554f511fdeb4c279bfdec0b4e/datetoken-0.3.2.tar.gz" } ] }