{"id":13502195,"url":"https://github.com/wroberts/pytimeparse","last_synced_at":"2025-04-08T12:07:31.944Z","repository":{"id":13739021,"uuid":"16433372","full_name":"wroberts/pytimeparse","owner":"wroberts","description":"A small Python module to parse various kinds of time expressions.","archived":false,"fork":false,"pushed_at":"2021-11-18T21:44:26.000Z","size":45,"stargazers_count":289,"open_issues_count":14,"forks_count":39,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T10:16:43.548Z","etag":null,"topics":["parser","python","python-2","python-3","time"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"zuiwuyuan/QuickAndroid","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wroberts.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.rst","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-01T12:12:16.000Z","updated_at":"2025-02-28T13:09:54.000Z","dependencies_parsed_at":"2022-09-23T15:05:46.670Z","dependency_job_id":null,"html_url":"https://github.com/wroberts/pytimeparse","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wroberts%2Fpytimeparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wroberts%2Fpytimeparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wroberts%2Fpytimeparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wroberts%2Fpytimeparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wroberts","download_url":"https://codeload.github.com/wroberts/pytimeparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838444,"owners_count":21004580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser","python","python-2","python-3","time"],"created_at":"2024-07-31T22:02:05.642Z","updated_at":"2025-04-08T12:07:31.913Z","avatar_url":"https://github.com/wroberts.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"=====================================\n pytimeparse: time expression parser\n=====================================\n\n.. image:: https://travis-ci.org/wroberts/pytimeparse.svg?branch=master\n    :target: https://travis-ci.org/wroberts/pytimeparse\n    :alt: Travis CI build status\n\n.. image:: https://coveralls.io/repos/wroberts/pytimeparse/badge.svg\n    :target: https://coveralls.io/r/wroberts/pytimeparse\n    :alt: Test code coverage\n\n.. image:: https://img.shields.io/pypi/v/pytimeparse.svg\n    :target: https://pypi.python.org/pypi/pytimeparse/\n    :alt: Latest Version\n\nCopyright (c) 2014 Will Roberts \u003cwildwilhelm@gmail.com\u003e\n\nLicensed under the MIT License (see source file ``timeparse.py`` for\ndetails).\n\nA small Python library to parse various kinds of time expressions,\ninspired by\n`this StackOverflow question \u003chttp://stackoverflow.com/questions/4628122/how-to-construct-a-timedelta-object-from-a-simple-string\u003e`_.\n\nThe single function ``pytimeparse.timeparse.timeparse`` defined in the\nlibrary (also available as ``pytimeparse.parse``) parses time\nexpressions like the following:\n\n- ``32m``\n- ``2h32m``\n- ``3d2h32m``\n- ``1w3d2h32m``\n- ``1w 3d 2h 32m``\n- ``1 w 3 d 2 h 32 m``\n- ``4:13``\n- ``4:13:02``\n- ``4:13:02.266``\n- ``2:04:13:02.266``\n- ``2 days,  4:13:02`` (``uptime`` format)\n- ``2 days,  4:13:02.266``\n- ``5hr34m56s``\n- ``5 hours, 34 minutes, 56 seconds``\n- ``5 hrs, 34 mins, 56 secs``\n- ``2 days, 5 hours, 34 minutes, 56 seconds``\n- ``1.2 m``\n- ``1.2 min``\n- ``1.2 mins``\n- ``1.2 minute``\n- ``1.2 minutes``\n- ``172 hours``\n- ``172 hr``\n- ``172 h``\n- ``172 hrs``\n- ``172 hour``\n- ``1.24 days``\n- ``5 d``\n- ``5 day``\n- ``5 days``\n- ``5.6 wk``\n- ``5.6 week``\n- ``5.6 weeks``\n\nIt returns the time as a number of seconds (an integer value if\npossible, otherwise a floating-point number)::\n\n    \u003e\u003e\u003e from pytimeparse import parse\n    \u003e\u003e\u003e parse('1.2 minutes')\n    72\n\nA number of seconds can be converted back into a string using the\n``datetime`` module in the standard library, as noted in\n`this other StackOverflow question \u003chttp://stackoverflow.com/questions/538666/python-format-timedelta-to-string\u003e`_::\n\n    \u003e\u003e\u003e from pytimeparse import parse\n    \u003e\u003e\u003e import datetime\n    \u003e\u003e\u003e parse('1 day, 14:20:16')\n    138016\n    \u003e\u003e\u003e str(datetime.timedelta(seconds=138016))\n    '1 day, 14:20:16'\n\nFuture work\n-----------\n\n1. Give the user more flexibility over which characters to use as\n   separators between fields in a time expression (e.g., ``+`` might\n   be useful).\n2. Internationalisation?\n3. Wow, https://github.com/bear/parsedatetime .\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwroberts%2Fpytimeparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwroberts%2Fpytimeparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwroberts%2Fpytimeparse/lists"}