{"id":15405721,"url":"https://github.com/davydovanton/relative_time","last_synced_at":"2025-04-17T01:53:54.610Z","repository":{"id":50986139,"uuid":"79955393","full_name":"davydovanton/relative_time","owner":"davydovanton","description":"Micro lib without any dependency for getting relative time","archived":false,"fork":false,"pushed_at":"2021-05-26T10:51:44.000Z","size":140,"stargazers_count":22,"open_issues_count":2,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-26T09:03:13.836Z","etag":null,"topics":["relative-time","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/davydovanton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-24T21:18:49.000Z","updated_at":"2023-03-20T22:05:24.000Z","dependencies_parsed_at":"2022-09-12T13:41:02.528Z","dependency_job_id":null,"html_url":"https://github.com/davydovanton/relative_time","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/davydovanton%2Frelative_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydovanton%2Frelative_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydovanton%2Frelative_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davydovanton%2Frelative_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davydovanton","download_url":"https://codeload.github.com/davydovanton/relative_time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249299815,"owners_count":21246911,"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":["relative-time","ruby"],"created_at":"2024-10-01T16:18:24.793Z","updated_at":"2025-04-17T01:53:54.591Z","avatar_url":"https://github.com/davydovanton.png","language":"Ruby","readme":"# RelativeTime\n[![Build Status](https://travis-ci.org/davydovanton/relative_time.svg?branch=master)](https://travis-ci.org/davydovanton/relative_time) [![Code Climate](https://codeclimate.com/github/davydovanton/relative_time/badges/gpa.svg)](https://codeclimate.com/github/davydovanton/relative_time) [![Test Coverage](https://codeclimate.com/github/davydovanton/relative_time/badges/coverage.svg)](https://codeclimate.com/github/davydovanton/relative_time/coverage)\n\nMicro lib without any dependency for getting relative time.\n\n\n## Motivation\nI love rails but sometimes we need to create web apps (or CLI) without rails and AS. That's why I created `#time_ago_in_words` analog on pure ruby without any dependencies.\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'relative_time'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install relative_time\n\n## Usage\nJust call `#in_words` method with any time object:\n\n```ruby\nRelativeTime.in_words(Date.today)\nRelativeTime.in_words(Time.now)          # =\u003e less than a minute\n\nRelativeTime.in_words(Time.now - 1 * 60) # =\u003e a minute ago\nRelativeTime.in_words(Time.now - 3 * 60) # =\u003e 3 minutes ago\n\nRelativeTime.in_words(Time.now + 1 * 60) # =\u003e in a minute\nRelativeTime.in_words(Time.now + 3 * 60) # =\u003e in 3 minutes\n```\n\nAlso you can use second argument as a from date:\n\n```ruby\ndate_from = Time.now - 60 * 60 # one hour ago\nRelativeTime.in_words(Time.now, date_from)          # =\u003e an hour ago\n```\n\n### Supported intervals\n\n* minutes\n* hours\n* days\n* weeks\n* months\n* years\n\n### I18n\nRelative time use [i18n](https://github.com/ruby-i18n/i18n) for pluralization and translation to other languages. For using specific locale just call `#in_words` with specific locale:\n\n```ruby\nRelativeTime.in_words(Time.now, locale: :ru)            # =\u003e через 3 часа\nRelativeTime.in_words(Time.now, date_from, locale: :ru) # =\u003e минуту назад\n```\n\nList of supported locales:\n\n* `en`\n* `id`\n* `ru`\n* `tr`\n* `uk`\n* `be`\n* `pt`\n* `fa`\n\n## Contributing\nBug reports and pull requests are welcome on GitHub at https://github.com/davydovanton/relative_time. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavydovanton%2Frelative_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavydovanton%2Frelative_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavydovanton%2Frelative_time/lists"}