{"id":15659520,"url":"https://github.com/mamantoha/humanize_time","last_synced_at":"2025-05-05T19:35:08.211Z","repository":{"id":52720639,"uuid":"126082985","full_name":"mamantoha/humanize_time","owner":"mamantoha","description":"Adds the humanize method to reports the approximate distance in time between two Time. humanize supports i18n translations too so it can be used in internationalized apps.","archived":false,"fork":false,"pushed_at":"2025-04-14T10:29:53.000Z","size":141,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T11:35:44.929Z","etag":null,"topics":["crystal","hacktoberfest","i18n","time"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/mamantoha.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":"2018-03-20T21:11:32.000Z","updated_at":"2025-04-14T10:29:21.000Z","dependencies_parsed_at":"2023-01-19T01:15:47.143Z","dependency_job_id":"1279e0f5-0b96-4cc5-8349-4e50dc40bd05","html_url":"https://github.com/mamantoha/humanize_time","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fhumanize_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fhumanize_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fhumanize_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mamantoha%2Fhumanize_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mamantoha","download_url":"https://codeload.github.com/mamantoha/humanize_time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252563041,"owners_count":21768391,"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":["crystal","hacktoberfest","i18n","time"],"created_at":"2024-10-03T13:17:15.212Z","updated_at":"2025-05-05T19:35:08.204Z","avatar_url":"https://github.com/mamantoha.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# humanize_time\n\n[![Crystal CI](https://github.com/mamantoha/humanize_time/actions/workflows/crystal.yml/badge.svg)](https://github.com/mamantoha/humanize_time/actions/workflows/crystal.yml)\n[![GitHub release](https://img.shields.io/github/release/mamantoha/humanize_time.svg)](https://github.com/mamantoha/humanize_time/releases)\n[![Commits Since Last Release](https://img.shields.io/github/commits-since/mamantoha/humanize_time/latest.svg)](https://github.com/mamantoha/humanize_time/pulse)\n[![License](https://img.shields.io/github/license/mamantoha/humanize_time.svg)](https://github.com/mamantoha/humanize_time/blob/master/LICENSE)\n\nReports the approximate distance in time between two `Time` objects.\nPass `include_seconds: true` if you want more detailed approximations when distance \u003c 1 min, 29 secs.\n\n`humanize_time` supports `i18n` translations too so it can be used in internationalized apps.\n\n`humanize_time` implementation is heavily inspired by (read: stolen) [distance_of_time_in_words](http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words) method.\nMany thanks to Rails community!\n\nDistances are reported based on the following table:\n\n| Value | Result |\n| --- | --- |\n| 0 \u003c-\u003e 29 secs                                                             | less than a minute   |\n| 30 secs \u003c-\u003e 1 min, 29 secs                                                | 1 minute             |\n| 1 min, 30 secs \u003c-\u003e 44 mins, 29 secs                                       | [2..44] minutes      |\n| 44 mins, 30 secs \u003c-\u003e 89 mins, 29 secs                                     | about 1 hour         |\n| 89 mins, 30 secs \u003c-\u003e 23 hrs, 59 mins, 29 secs                             | about [2..24] hours  |\n| 23 hrs, 59 mins, 30 secs \u003c-\u003e 41 hrs, 59 mins, 29 secs                     | 1 day                |\n| 41 hrs, 59 mins, 30 secs  \u003c-\u003e 29 days, 23 hrs, 59 mins, 29 secs           | [2..29] days         |\n| 29 days, 23 hrs, 59 mins, 30 secs \u003c-\u003e 44 days, 23 hrs, 59 mins, 29 secs   | about 1 month        |\n| 44 days, 23 hrs, 59 mins, 30 secs \u003c-\u003e 59 days, 23 hrs, 59 mins, 29 secs   | about 2 months       |\n| 59 days, 23 hrs, 59 mins, 30 secs \u003c-\u003e 1 yr minus 1 sec                    | [2..12] months       |\n| 1 yr \u003c-\u003e 1 yr, 3 months                                                   | about 1 year         |\n| 1 yr, 3 months \u003c-\u003e 1 yr, 9 months                                         | over 1 year          |\n| 1 yr, 9 months \u003c-\u003e 2 yr minus 1 sec                                       | almost 2 years       |\n| 2 yrs \u003c-\u003e max time or date                                                | (same rules as 1 yr) |\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  humanize_time:\n    github: mamantoha/humanize_time\n```\n\n## Usage\n\n```crystal\nrequire \"humanize_time\"\n\nHumanizeTime.locale = \"es\" # or `I18n.locale = \"es\"`\n\nHumanizeTime.distance_of_time_in_words(42.minutes.ago, Time.local)\n# =\u003e 42 minutos\nHumanizeTime.distance_of_time_in_words(3.seconds.ago, Time.local, include_seconds: true)\n# =\u003e menos de 5 segundos\n```\n\n## Available locales\n\nLocale data synced with [rails-i18n](https://github.com/svenfuchs/rails-i18n) repository from files found in [rails/locale](http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale/) directory.\n\nAvailable 123 locales:\n\n\u003e [\"af\", \"ar\", \"az\", \"be\", \"bg\", \"bn\", \"bs\", \"ca\", \"cnr\", \"cs\", \"cy\", \"da\", \"de\", \"de-AT\", \"de-CH\", \"de-DE\", \"dz\", \"el\", \"el-CY\", \"en\", \"en-AU\", \"en-CA\", \"en-CY\", \"en-GB\", \"en-IE\", \"en-IN\", \"en-NZ\", \"en-TT\", \"en-US\", \"en-ZA\", \"eo\", \"es\", \"es-419\", \"es-AR\", \"es-CL\", \"es-CO\", \"es-CR\", \"es-EC\", \"es-ES\", \"es-MX\", \"es-NI\", \"es-PA\", \"es-PE\", \"es-US\", \"es-VE\", \"et\", \"eu\", \"fa\", \"fi\", \"fr\", \"fr-CA\", \"fr-CH\", \"fr-FR\", \"fy\", \"gd\", \"gl\", \"he\", \"hi\", \"hi-IN\", \"hr\", \"hu\", \"hy\", \"id\", \"is\", \"it\", \"it-CH\", \"ja\", \"ka\", \"kk\", \"km\", \"kn\", \"ko\", \"lb\", \"lo\", \"lt\", \"lv\", \"mg\", \"mk\", \"ml\", \"mn\", \"mr-IN\", \"ms\", \"nb\", \"ne\", \"nl\", \"nn\", \"oc\", \"or\", \"pa\", \"pap-AW\", \"pap-CW\", \"pl\", \"pt\", \"pt-BR\", \"rm\", \"ro\", \"ru\", \"sc\", \"sk\", \"sl\", \"sq\", \"sr\", \"st\", \"sv\", \"sv-FI\", \"sv-SE\", \"sw\", \"ta\", \"te\", \"th\", \"tl\", \"tr\", \"tt\", \"ug\", \"uk\", \"ur\", \"uz\", \"vi\", \"wo\", \"zh-CN\", \"zh-HK\", \"zh-TW\", \"zh-YUE\"]\n\nTo re-sync locales run:\n\n```console\ncrystal tool/sync_locales.cr\n```\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/mamantoha/humanize_time/fork\u003e)\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [mamantoha](https://github.com/mamantoha) Anton Maminov - creator, maintainer\n\n## Special thanks\n\n- [rails-i18n](https://github.com/svenfuchs/rails-i18n) community - Locale data\n- [Morgan Aubert](https://github.com/ellmetha) - creator and maintainer of [i18n](https://github.com/crystal-i18n/i18n) an internationalization library for Crystal\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamantoha%2Fhumanize_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmamantoha%2Fhumanize_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmamantoha%2Fhumanize_time/lists"}