{"id":15442854,"url":"https://github.com/pyunits/pyunit-time","last_synced_at":"2025-09-05T08:32:43.408Z","repository":{"id":37398057,"uuid":"238234871","full_name":"pyunits/pyunit-time","owner":"pyunits","description":"一个简单易用的 Python 模块，用于通过字符串来操作日期/时间。正则时间提取，字符串时间解析，字符串时间提取。中文时间提取，一句话里面提取时间","archived":false,"fork":false,"pushed_at":"2024-07-03T08:01:27.000Z","size":948,"stargazers_count":74,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T13:16:26.144Z","etag":null,"topics":["python3","time"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyunits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-04T15:10:25.000Z","updated_at":"2024-09-10T08:45:18.000Z","dependencies_parsed_at":"2024-10-31T07:03:22.271Z","dependency_job_id":"464f986f-1301-499d-8891-a81f9ff7a1bd","html_url":"https://github.com/pyunits/pyunit-time","commit_stats":{"total_commits":49,"total_committers":2,"mean_commits":24.5,"dds":"0.020408163265306145","last_synced_commit":"e9114ad7b49778a15fba5429365f3dd10a26e2ae"},"previous_names":["pyunit/pyunit-time"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyunits","download_url":"https://codeload.github.com/pyunits/pyunit-time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232032123,"owners_count":18462971,"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":["python3","time"],"created_at":"2024-10-01T19:30:49.209Z","updated_at":"2024-12-31T22:08:18.232Z","avatar_url":"https://github.com/pyunits.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **pyUnit_time**\n\n    介绍： 基于Python实现的、中文字符串解析时间。输入当前时刻，在输入一句中文语句，\n          自动推导语句所表达的下一个时刻。\n          比如：当前时刻是2020年4月22日，输入：这个月的第三个星期日是哪天？输出：2020年4月19日。\n\n[![](https://img.shields.io/badge/Python-3.8-green.svg)](https://pypi.org/project/pyunit-time/)\n[![](https://img.shields.io/badge/Email-jtyoui@qq.com-red.svg)]()\n\n### 安装\n\n    pip install pyunit-time\n\n### 推导类型\n\n1. 年、月、日、时、分、秒\n2. 周、天\n3. 中国节日\n4. 国外特殊节日\n5. 农历、阳历\n6. 天干地支\n7. 二十四节气\n\n## 测试\n\n```python\nfrom pyunit_time import Time\n\n\ndef time():\n    \"\"\"字符字符串时间解析\"\"\"\n    print(Time('2020-4-22 00:00:00').parse('这个月的第三个星期天'))\n    # [{'key': '这个月第3个星期天', 'keyDate': '2020-04-19 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('前2年的国庆节的后一天晚上8点半'))\n    # [{'key': '前2年国庆节后1天晚上8点半', 'keyDate': '2018-09-30 20:30:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('上上个月'))\n    # [{'key': '上上个月', 'keyDate': '2020-02-22 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('今天晚上8点'))\n    # [{'key': '今天晚上8点', 'keyDate': '2020-04-22 20:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('今年儿童节晚上九点一刻'))\n    # [{'key': '今年儿童节晚上9点1刻', 'keyDate': '2020-06-01 21:15:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('今天中午十二点'))\n    # [{'key': '今天中午12点', 'keyDate': '2020-04-22 12:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('明年春节'))\n    # [{'key': '明年春节', 'keyDate': '2021-02-12 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('明年的感恩节'))\n    # [{'key': '明年感恩节', 'keyDate': '2021-11-25 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('下3个星期1早上7点半'))\n    # [{'key': '下3个星期1早上7点半', 'keyDate': '2020-05-11 07:30:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('今年的大寒'))\n    # [{'key': '今年大寒', 'keyDate': '2021-01-20 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('2019年12月'))\n    # [{'key': '2019年12月', 'keyDate': '2019-12-01 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('8年前'))\n    # [{'key': '8年前', 'keyDate': '2012-04-22 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('三天以后'))\n    # [{'key': '3天以后', 'keyDate': '2020-04-25 00:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('三天之内的下午3点'))\n    # [{'key': '3天之内下午3点', 'keyDate': '2020-04-25 15:00:00', 'baseDate': '2020-04-22 00:00:00'}]\n\n    print(Time('2020-4-22 00:00:00').parse('后三天的下午4点56秒'))\n    # [{'key': '后3天下午4点56秒', 'keyDate': '2020-04-25 16:00:56', 'baseDate': '2020-04-22 00:00:00'}]\n\n\nif __name__ == '__main__':\n    time()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyunits%2Fpyunit-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyunits%2Fpyunit-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyunits%2Fpyunit-time/lists"}