{"id":47323946,"url":"https://github.com/kusen-alpha/gggdtparser","last_synced_at":"2026-03-17T18:44:05.761Z","repository":{"id":152338163,"uuid":"618330966","full_name":"kusen-alpha/gggdtparser","owner":"kusen-alpha","description":"通用、便捷、准确的字符串时间解析工具，在一些特殊场景可能是目前字符串时间解析最好用、解析速度最快的库。","archived":false,"fork":false,"pushed_at":"2025-06-26T08:11:33.000Z","size":62,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-28T02:23:06.649Z","etag":null,"topics":["date-parser","date-parsing","dateparser","datetime","datetime-parser","datetime-parsing","dateutil","dateutil-python","dateutils","dtparser","gggdtparser"],"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/kusen-alpha.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-24T08:38:30.000Z","updated_at":"2025-06-26T08:11:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"6dd9b4b1-b1f8-4fbd-bccb-949f7a7cb353","html_url":"https://github.com/kusen-alpha/gggdtparser","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/kusen-alpha/gggdtparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusen-alpha%2Fgggdtparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusen-alpha%2Fgggdtparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusen-alpha%2Fgggdtparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusen-alpha%2Fgggdtparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kusen-alpha","download_url":"https://codeload.github.com/kusen-alpha/gggdtparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kusen-alpha%2Fgggdtparser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30628514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-parser","date-parsing","dateparser","datetime","datetime-parser","datetime-parsing","dateutil","dateutil-python","dateutils","dtparser","gggdtparser"],"created_at":"2026-03-17T18:44:05.296Z","updated_at":"2026-03-17T18:44:05.743Z","avatar_url":"https://github.com/kusen-alpha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gggdtparser\n\n通用时间解析器(General General General DateTime Parser)\n，是基于Python编写的字符串时间抽取解析工具,经过了众多测试用例进行测试，具有通用、高效、准确的解析能力。\n\n## 项目背景\n\n1. 在日常开发中，特别是爬虫采集时，来自各种语言、各种格式、语义化话的字符串时间，对其解析非常复杂繁琐。\n2. 通用的字符串解析需要考虑的情况很多，既要尽可能多地满足各类字符串时间格式，还需对解析出的结果的准确有很高要求。\n3. Python中各类解析库，在解析前的要求很高，只能解析无噪声的字符串时间，极为不方便。\n\n## 项目原理\n\n1. 采用正则的方式完成对时间的抽取，进一步对抽取到的时间进行解析，即抽取和解析一体，用户给与的时间文本可以有很多非时间内容，使得解析更加便捷。\n2. 对语义话时间进行计算，对其他语言进行支持。\n3. 使用正则规则，后续增加特殊时间格式较为方便。\n\n## 项目特色\n\n1. 模糊抽取解析\n2. 解析速度快\n3. 支持自定义解析规则\n\n## 使用方法\n\n### 安装\n\n    pip install gggdtparser\n\n### 使用\n\n    import gggdtparser\n    parse_dt = gggdtparser.parse(\"发布：2022/02/02 02:02:02，来源：xxx网\")\n    print(parse_dt)  # 2022-02-02 02:02:02\n\n### 测试\n\n    import datetime\n    import gggdtparser\n    parse_dt = gggdtparser.parse(\"发布：2022/02/02 02:02:02，来源：xxx网\")\n    is_right = gggdtparser.check(parse_dt, datetime.datetime(year=2022, month=2, day=2, hour=2, minute=2, second=2))\n    print(is_right)  # True\n\n## 使用案例\n\n### 详细案例\n\n1. 参考dtformat.md中支持的格式。\n2. 参考test.py中的测试案例。\n\n### 特色案例\n\n1. 语义时间的支持\n\n```\n   il y a 26 minutes\n   il y a 1 heure\n   Publié aujourd’hui à 10h34, modifié à 10h39\n   23分鐘前\n   ......      \n\n```\n\n2. 允许噪音\n\n```\n   发布于：2023/2/20\n   Hoje Macau - 4 Abr 2023 \n   2023年04月10日 07:46　来源：新闻网\n   ......\n```\n\n3. 支持多种语言\n\n```\n   31 март 2023  # 俄语\n   31 de marzo de 2023  # 西班牙语\n   27 Fev 2023  # 卡拜尔语\n   ......\n```\n\n4. 指定formats解析\n\n```python\nimport gggdtparser\n\ndt = gggdtparser.parse(\"2023-02-20\", format_list=[\"%Y-%m-%d\"])\nprint(dt)\n```\n\n5. 指定正则解析\n\n正则使用有名分组形式，对应关系如下：\n\n| 关键词 |     含义      |            示例            |\n|:---:|:-----------:|:------------------------:|\n|  Y  |      年      |      (?P\\\u003cY\u003e\\d{4})年       |\n|  m  |      月      |     (?P\\\u003cm \u003e\\d{1,2})月      |\n|  d  |      日      |     (?P\\\u003cd\u003e\\d{1,2})日      |\n|  H  |      时      |     (?P\\\u003cH\u003e\\d{1,2})时      |\n|  M  |      分      |     (?P\\\u003cM\u003e\\d{1,2})分      |\n|  S  |      秒      |     (?P\\\u003cS\u003e\\d{1,2})秒      |\n| bY  |   在...年前    | (?P\\\u003cbY\u003e\\d+)\\s*(年)\\s*(前)  |\n| bm  |   在...月前    | (?P\\\u003cbm\u003e\\d+)\\s*(月)\\s*(前)  |\n| bd  |   在...日前    | (?P\\\u003cbd\u003e\\d+)\\s*(天)\\s*(前)  |\n| bH  |   在...时前    | (?P\\\u003cbH\u003e\\d+)\\s*(小时)\\s*(前) |\n| bM  |   在...分前    | (?P\\\u003cbM\u003e\\d+)\\s*(分钟)\\s*(前) |\n| bS  |   在...秒前    | (?P\\\u003cbS\u003e\\d+)\\s*(秒)\\s*(前)  |\n| ba  |   在...星期前   | (?P\\\u003cba\u003e\\d+)\\s*(周)\\s*(前)  |\n| wY  |   在...年内    | (?P\\\u003cwY\u003e\\d+)\\s*(年)\\s*(内)  |\n| wm  |   在...月内    | (?P\\\u003cwm\u003e\\d+)\\s*(月)\\s*(内) |\n| wd  |   在...日内    | (?P\\\u003cwd\u003e\\d+)\\s*(天)\\s*(内)  |\n| wH  |   在...时内    | (?P\\\u003cwH\u003e\\d+)\\s*(小时)\\s*(内) |\n| wM  |   在...分内    | (?P\\\u003cwM\u003e\\d+)\\s*(分钟)\\s*(内) |\n| wS  |   在...秒内    | (?P\\\u003cwS\u003e\\d+)\\s*(秒)\\s*(内)  |\n| wa  |   在...星期内   | (?P\\\u003cwa\u003e\\d+)\\s*(周)\\s*(内)  |\n| aY  |   在...年后    | (?P\\\u003cwY\u003e\\d+)\\s*(年)\\s*(后)  |\n| am  |   在...月后    | (?P\\\u003cwm\u003e\\d+)\\s*(月)\\s*(后) |\n| ad  |   在...日后    | (?P\\\u003cwd\u003e\\d+)\\s*(天)\\s*(后)  |\n| aH  |   在...时后    | (?P\\\u003cwH\u003e\\d+)\\s*(小时)\\s*(后) |\n| aM  |   在...分后    | (?P\\\u003cwM\u003e\\d+)\\s*(分钟)\\s*(后) |\n| aS  |   在...秒后    | (?P\\\u003cwS\u003e\\d+)\\s*(秒)\\s*(后)  |\n| aa  |   在...星期后   | (?P\\\u003cwa\u003e\\d+)\\s*(周)\\s*(后)  |\n| sd  | 今天/昨天/前天/刚刚 |        (?P\\\u003csd\u003e前天)        | \n| apm |    上午下午     |       (?P\\\u003capm\u003eam)        | \n\n示例如下：\n\n```python\nimport gggdtparser\n\ndt = gggdtparser.parse(\"2023-02-20\",\n                       regex_list=[r\"(?P\u003cY\u003e\\d{4})(?P\u003cm\u003e\\d{2})(?P\u003cd\u003e\\d{2})\"])\nprint(dt)\n```\n\n6. 自定义翻译\n\n```python\nimport gggdtparser\n\n\ndef translate(s):\n    # 翻译\n    return \"\"\n\n\ndt = gggdtparser.parse(\"xxx\", translate_func=translate)\nprint(dt)\n\n```\n\n7. 时间范围解析\n```python\n\nimport datetime\nfrom gggdtparser import parse_frame\n\nprint(parse_frame('2022年10月1日至2023年10月1日'))\nprint(parse_frame('10个月', regex_list=[None, ('(?P\u003cam\u003e\\d+)\\s*(个)?月',)], base_datetime=datetime.datetime(year=2023, month=1, day=1)))\n\n```\n\n## 待完善\n\n1. 兼容更多语言\n2. 对时区的解析\n\n## 关于作者\n\n1. 邮箱：1194542196@qq.com\n2. 目前对常见的时间格式解析支持比较全，但是一些特殊的时间格式和其他语言的支持不够完善，如果遇到解析bug\n   或不能解析的时间格式，可以私信作者，你们的提供越多，本库才能更完善。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkusen-alpha%2Fgggdtparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkusen-alpha%2Fgggdtparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkusen-alpha%2Fgggdtparser/lists"}