{"id":13571009,"url":"https://github.com/shinux/PyTime","last_synced_at":"2025-04-04T07:32:40.660Z","repository":{"id":30175599,"uuid":"33726019","full_name":"shinux/PyTime","owner":"shinux","description":"PyTime is an easy-use Python module which aims to operate date/time/datetime by string.","archived":false,"fork":false,"pushed_at":"2022-11-05T02:47:26.000Z","size":80,"stargazers_count":158,"open_issues_count":0,"forks_count":25,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-21T05:07:30.334Z","etag":null,"topics":["date-time","datetime","python","pytime"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-10T11:53:14.000Z","updated_at":"2024-05-09T17:58:35.000Z","dependencies_parsed_at":"2023-01-14T16:28:05.181Z","dependency_job_id":null,"html_url":"https://github.com/shinux/PyTime","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinux%2FPyTime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinux%2FPyTime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinux%2FPyTime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinux%2FPyTime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinux","download_url":"https://codeload.github.com/shinux/PyTime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247139297,"owners_count":20890198,"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":["date-time","datetime","python","pytime"],"created_at":"2024-08-01T14:00:57.469Z","updated_at":"2025-04-04T07:32:35.649Z","avatar_url":"https://github.com/shinux.png","language":"Python","readme":"# PyTime\n[![Build Status](https://travis-ci.org/shinux/PyTime.svg?branch=master)](https://travis-ci.org/shinux/PyTime)\n[![PyPI version](https://badge.fury.io/py/pytime.svg)](http://badge.fury.io/py/pytime)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/PyTime.svg)](https://pypi.python.org/pypi/pytime/)\n\nPyTime is an easy-use Python module which aims to operate date/time/datetime by string.\n\nPyTime allows you using nonregular datetime string to generate and calculate datetime at most situation.\n\nIt Also provides you some simple useful methods for getting datetime you want.\n\n## Install\n```python\npip install pytime\n```\n## Sample Usage\n\nCalculate `datetime` all by string, accept unit for short or overall length, support out of order or in capital unit:\n```python\n\u003e\u003e\u003efrom pytime import pytime\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.before('2015.5.17', '2years 3mon 23week 3d 2hr')     # 2years 3months 23weeks 3days 2hours before 2015.5.17\ndatetime.datetime(2012, 9, 5, 22, 0)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.after(pytime.tomorrow('15.5.17'), '23month3dy29minu')   # 23months 3days 29minutes after 2015-5-17's next day\ndatetime.datetime(2017, 4, 21, 0, 29)\n```\n\nParse nonregular datetime string to datetime:\n```python\n\u003e\u003e\u003epytime.parse('April 3rd 2015')\ndatetime.date(2015, 4, 3)\n\u003e\u003e\u003epytime.parse('Oct, 1st. 2015')\ndatetime.date(2015, 10, 1)\n\u003e\u003e\u003epytime.parse('NOV21th2015')\ndatetime.date(2015, 11, 21)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.parse('2015517')\ndatetime.date(2015, 5, 17)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.parse('5/17/15')\ndatetime.date(2015, 5, 17)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.parse('92-11-2')\ndatetime.date(1992, 11, 2)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.parse(1432310400)          # support datetimestamp for all function\ndatetime.datetime(2015, 5, 23, 0, 0)\n```\n\n\nCalculate week and month in a easy way. Normally we want to use these binate date in script, from Monday to next Monday which means 00:00:00-23:59:59, and Month from 1st to next 1st in the same way, but if you want clean date interval, you could set `pytime.next_week(clean=True)` to get the clean date for next week etc.\n```python\n\u003e\u003e\u003epytime.this_week()\n(datetime.date(2015, 5, 11), datetime.date(2015, 5, 18))\n\n\u003e\u003e\u003epytime.next_week('2015-6-14')                         # 2015-6-14's next week for script\n(datetime.date(2015, 6, 15), datetime.date(2015, 6, 23))\n\n\u003e\u003e\u003epytime.last_week(pytime.mother(2013), True)           # 2013 Mother's Day's last week\n(datetime.date(2013, 5, 13), datetime.date(2013, 5, 20))\n\n\u003e\u003e\u003epytime.next_month('2015-10-1')\n(datetime.date(2015, 11, 1), datetime.date(2015, 12, 1))\n```\n\nPytime support calculate timedelta by string even between `date` and `datetime`, merely set the `date` to that day's midnight:\n```python\n\u003e\u003e\u003epytime.count('2015-5-17 23:23:23', pytime.tomorrow())\ndatetime.timedelta(1, 84203)\n```\n\nGet common festivals for designated year:\n```python\n\u003e\u003e\u003epytime.father()              # Father's Day\ndatetime.date(2015, 6, 21)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.mother(2016)          # 2016 Mother's Day\ndatetime.date(2016, 5, 8)\n\u003e\u003e\u003e\n\u003e\u003e\u003epytime.easter(1999)          # 1999 Easter\ndatetime.date(1999, 4, 4)\n\u003e\u003e\u003epytime.vatertag(2020)        # Fater's Day in Germany\ndatetime.date(2020, 5, 21)\n```\n\n\nGet days between two date.\n```python\n\u003e\u003e\u003epytime.days_range('2015-5-17', '2015-5-23')\n[datetime.date(2015, 5, 23),\n datetime.date(2015, 5, 22),\n datetime.date(2015, 5, 21),\n datetime.date(2015, 5, 20),\n datetime.date(2015, 5, 19),\n datetime.date(2015, 5, 18),\n datetime.date(2015, 5, 17)]\n```\n...\n\nand other useful methods.\n\n## Contributors\n- Sinux\n- [felipevolpone](https://github.com/felipevolpone)\n- [fy](https://github.com/fy0)\n- [Joshua Dong](https://github.com/Joshua1986)\n- [Dinko Pehar](https://github.com/PinkFrojd)\n\n\n## License\n\nMIT\n","funding_links":[],"categories":["Date and Time","资源列表","📦 Packages","Python","日期和时间","Date and Time [🔝](#readme)","Awesome Python"],"sub_categories":["日期和时间","Python","Automatic Plotting","Date and Time"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinux%2FPyTime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinux%2FPyTime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinux%2FPyTime/lists"}