{"id":13493698,"url":"https://github.com/hustcc/timeago","last_synced_at":"2025-05-16T01:07:11.388Z","repository":{"id":8776708,"uuid":"59721185","full_name":"hustcc/timeago","owner":"hustcc","description":":hourglass: Simple library used to format datetime with `*** time ago` statement. eg: \"3 hours ago\". ","archived":false,"fork":false,"pushed_at":"2022-09-14T04:42:03.000Z","size":120,"stargazers_count":223,"open_issues_count":5,"forks_count":37,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-08T12:04:54.239Z","etag":null,"topics":["datetime","format-datetime","multi-language","python","timeago"],"latest_commit_sha":null,"homepage":"http://timeago.org","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/hustcc.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":"2016-05-26T05:00:48.000Z","updated_at":"2025-03-25T14:04:43.000Z","dependencies_parsed_at":"2022-08-07T04:16:45.985Z","dependency_job_id":null,"html_url":"https://github.com/hustcc/timeago","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftimeago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftimeago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftimeago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hustcc%2Ftimeago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hustcc","download_url":"https://codeload.github.com/hustcc/timeago/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"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":["datetime","format-datetime","multi-language","python","timeago"],"created_at":"2024-07-31T19:01:17.893Z","updated_at":"2025-05-16T01:07:06.380Z","avatar_url":"https://github.com/hustcc.png","language":"Python","readme":"# timeago\n\nA very simple python lib, used to format datetime with `*** time ago` statement. Javascript version here. [timeago.js](https://github.com/hustcc/timeago.js).\n\n[![Build Status](https://travis-ci.org/hustcc/timeago.svg?branch=master)](https://travis-ci.org/hustcc/timeago) [![PyPi Status](https://img.shields.io/pypi/v/timeago.svg)](https://pypi.python.org/pypi/timeago) [![Python Versions](https://img.shields.io/pypi/pyversions/timeago.svg)](https://pypi.python.org/pypi/timeago) \n\nSuch as: \n\n```\njust now\n12 seconds ago\n3 minutes ago\n2 hours ago\n24 days ago\n6 months ago\n2 years ago\n\nin 12 seconds\nin 3 minutes\nin 2 hours\nin 24 days\nin 6 months\nin 2 years\n```\n\nFor other languages see below. \n\n## Install\n\n```sh\npip install timeago\n```\n\n\n## Usage \u0026 Example\n\n```py\n# -*- coding: utf-8 -*-\nimport timeago, datetime\n\nnow = datetime.datetime.now() + datetime.timedelta(seconds = 60 * 3.4)\n\ndate = datetime.datetime.now()\n\n# locale\nprint (timeago.format(date, now, 'zh_CN')) # will print `3分钟前`\n\n# input datetime\nprint (timeago.format(date, now)) # will print 3 minutes ago\n\n# input timedelta\nprint (timeago.format(datetime.timedelta(seconds = 60 * 3.4))) # will print 3 minutes ago\n\n# input date, auto add time(0, 0, 0)\nprint (timeago.format(datetime.date(2016, 5, 27), now))\n\n# input datetime formatted string\nprint (timeago.format('2016-05-27 12:12:03', '2016-05-27 12:12:12')) # will print just now\n\n# inverse two parameters\nprint (timeago.format('2016-05-27 12:12:12', '2016-05-27 12:12:03')) # will print a while\n\n```\n\n\n## Method \u0026 Parameter\n\nonly one API **`format`**.\n\nThree parameters of method `format`:\n\n - **`date`**: the parameter which will be formatted, must be instance of `datetime` / `timedelta` or datetime formatted string.\n - **`now`**: reference time, must be instance of `datetime` or datetime formatted string.\n - **`locale`**: the locale code, default `en`. \n\n\n## Locale\n\nAt the time we're speaking, [following locale](src/timeago/locales) are available:\n - `ar`\n - `bg`\n - `ca`\n - `da`\n - `de`\n - `el`\n - `en`\n - `en_short`\n - `es`\n - `eu`\n - `fa_IR`\n - `fi`\n - `fr`\n - `gl`\n - `guj_IN`\n - `he`\n - `hu`\n - `in_BG`\n - `in_HI`\n - `in_ID`\n - `is`\n - `it`\n - `ja`\n - `ko`\n - `lt`\n - `ml`\n - `my`\n - `nb_NO`\n - `nl`\n - `nn_NO`\n - `pl`\n - `pt_BR`\n - `pt_PT`\n - `ro`\n - `ru`\n - `sk`\n - `sv_SE`\n - `ta`\n - `th`\n - `tr`\n - `uk`\n - `vi`\n - `zh_CN`\n - `zh_TW`\n\n\n## Localization\n\n1. Fork the project\n2. Create a locale python script called `[name_of_your_locale].py` following the existing other locales.\n3. Add the name of your locale in the Readme (both in MD and in RST) to keep it updated (**alphabetically**).\n4. Add test case following the [english model](/test/testcase.py#L50)\n5. Create the Pull Request.\n\n### Notes\n\nFor complicated plurals, you can take example on the PL :flag-pl: locale [here](src/timeago/locales/pl.py)\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Ftimeago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhustcc%2Ftimeago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhustcc%2Ftimeago/lists"}