{"id":13502202,"url":"https://github.com/KoffeinFlummi/Chronyk","last_synced_at":"2025-03-29T10:32:49.848Z","repository":{"id":20735366,"uuid":"24019627","full_name":"KoffeinFlummi/Chronyk","owner":"KoffeinFlummi","description":"A Python 3 library for parsing human-written times and dates","archived":false,"fork":false,"pushed_at":"2019-12-08T05:50:11.000Z","size":314,"stargazers_count":346,"open_issues_count":8,"forks_count":17,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-31T21:35:43.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/KoffeinFlummi.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":"2014-09-14T10:51:14.000Z","updated_at":"2024-10-03T03:09:39.000Z","dependencies_parsed_at":"2022-08-07T09:16:15.932Z","dependency_job_id":null,"html_url":"https://github.com/KoffeinFlummi/Chronyk","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KoffeinFlummi%2FChronyk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KoffeinFlummi%2FChronyk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KoffeinFlummi%2FChronyk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KoffeinFlummi%2FChronyk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KoffeinFlummi","download_url":"https://codeload.github.com/KoffeinFlummi/Chronyk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174207,"owners_count":20735406,"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":[],"created_at":"2024-07-31T22:02:05.894Z","updated_at":"2025-03-29T10:32:49.485Z","avatar_url":"https://github.com/KoffeinFlummi.png","language":"Python","funding_links":[],"categories":["Date and Time","资源列表","Python","📦 Packages","日期和时间","Date and Time [🔝](#readme)","Awesome Python"],"sub_categories":["日期和时间","Python","Automatic Plotting","Date and Time"],"readme":"Chronyk\n======\n\n[![Build Status](http://img.shields.io/travis/KoffeinFlummi/Chronyk/master.svg?style=flat)](https://travis-ci.org/KoffeinFlummi/Chronyk) [![Code Coverage](http://img.shields.io/coveralls/KoffeinFlummi/Chronyk.svg?style=flat)](https://coveralls.io/r/KoffeinFlummi/Chronyk) [![PyPi](http://img.shields.io/pypi/v/Chronyk.svg?style=flat)](https://pypi.python.org/pypi/Chronyk) [![License](http://img.shields.io/pypi/l/Chronyk.svg?style=flat)](https://github.com/KoffeinFlummi/Chronyk/blob/master/LICENSE)\n\nA small Python 3 library containing some handy tools for handling time, especially when it comes to interfacing with those pesky humans.\n\n\n## Features\n- Parsing human-written strings (\"10 minutes ago\", \"10. April 2015\", \"2014-02-15\"...)\n- Relative time string creation (\"in 2 hours\", \"5 hours ago\")\n- Various input formats\n- Easy to use\n\n\n## Installation\n\n```bash\n$ pip install chronyk\n```\n\n\n## Usage\n\n**Basic:**\n\n```python\n\u003e\u003e\u003e from chronyk import Chronyk\n\u003e\u003e\u003e t = Chronyk(1410531179.0)\n\u003e\u003e\u003e t = Chronyk(\"May 2nd, 2016 12:51 am\")\n\u003e\u003e\u003e t = Chronyk(\"yesterday\")\n\u003e\u003e\u003e t = Chronyk(\"21. 8. 1976 23:18\")\n\u003e\u003e\u003e t = Chronyk(\"2 days and 30 hours ago\")\n\u003e\u003e\u003e t.ctime()\n'Tue Sep  9 05:59:39 2014'\n\u003e\u003e\u003e t.timestamp()\n1410235179.0\n\u003e\u003e\u003e t.timestring()\n'2014-09-09 05:59:39'\n\u003e\u003e\u003e t.timestring(\"%Y-%m-%d\")\n'2014-09-09'\n\u003e\u003e\u003e t.relativestring()\n'3 days ago'\n\u003e\u003e\u003e t.date()\ndatetime.date(2014, 9, 9)\n\u003e\u003e\u003e t.datetime()\ndatetime.datetime(2014, 9, 9, 5, 59, 39)\n```\n\n**Input validation:**\n\n```python\nimport sys\nimport chronyk\n\ntimestr = input(\"Please enter the date you were born: \")\ntry:\n    date = chronyk.Chronyk(timestr, allowfuture=False)\nexcept chronyk.DateRangeError:\n    print(\"Yeah, right.\")\n    sys.exit(1)\nexcept ValueError:\n    print(\"Failed to parse birthdate.\")\n    sys.exit(1)\nelse:\n    print(\"You were born {}\".format(date.relativestring()))\n```\n\n**Timezones:**\n\nBy default, the Chronyk constructor uses local time, and every method by default uses whatever was passed to the constructor as well.\n\nAlmost all methods, however, have a timezone keyargument that you can use to define your local offset from UTC in seconds (positive for west, negative for east).\n\nIf you want to use a certain timezone for more than one method, you can also change the `timezone` instance attribute itself:\n```python\n\u003e\u003e\u003e t = Chronyk(\"4 hours ago\", timezone=0) # using UTC\n\u003e\u003e\u003e t.ctime()\n'Tue Sep  9 10:53:42 2014'\n\u003e\u003e\u003e t.timezone = -3600 # changes to CET (UTC+1)\n\u003e\u003e\u003e t.relativeTime()\n'5 hours ago'\n\u003e\u003e\u003e t.ctime()\n'Tue Sep  9 09:53:42 2014'\n```\n\nThis uses the local relative time and returns a time string relative to current UTC:\n```python\n\u003e\u003e\u003e t = Chronyk(\"4 hours ago\")\n\u003e\u003e\u003e t.relativestring(timezone=0)\n'3 hours ago'\n```\n\nThis uses a UTC timestamp and returns a time string relative to local time:\n```python\n\u003e\u003e\u003e t = Chronyk(1410524713.69, timezone=0)\n\u003e\u003e\u003e t.relativestring(timezone=chronyk.LOCALTZ)\n'2 hours ago'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKoffeinFlummi%2FChronyk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKoffeinFlummi%2FChronyk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKoffeinFlummi%2FChronyk/lists"}