{"id":17036126,"url":"https://github.com/digaev/to_duration","last_synced_at":"2025-04-12T12:52:23.066Z","repository":{"id":62559172,"uuid":"75807538","full_name":"digaev/to_duration","owner":"digaev","description":"A Ruby gem for converting seconds into human-readable format","archived":false,"fork":false,"pushed_at":"2020-03-01T04:21:37.000Z","size":19,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T00:39:41.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/digaev.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":"2016-12-07T06:43:03.000Z","updated_at":"2023-08-28T07:34:49.000Z","dependencies_parsed_at":"2022-11-03T11:15:48.951Z","dependency_job_id":null,"html_url":"https://github.com/digaev/to_duration","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fto_duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fto_duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fto_duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digaev%2Fto_duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digaev","download_url":"https://codeload.github.com/digaev/to_duration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571604,"owners_count":21126519,"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-10-14T08:49:26.790Z","updated_at":"2025-04-12T12:52:23.048Z","avatar_url":"https://github.com/digaev.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# to_duration\n\n[![Gem Version](https://badge.fury.io/rb/to_duration.svg)](https://badge.fury.io/rb/to_duration) [![Build Status](https://travis-ci.org/digaev/to_duration.svg)](https://travis-ci.org/digaev/to_duration) [![Coverage Status](https://coveralls.io/repos/github/digaev/to_duration/badge.svg?branch=master)](https://coveralls.io/github/digaev/to_duration?branch=master)\n\nA Ruby gem for converting seconds into human-readable format.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'to_duration'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install to_duration\n\n## Usage\n\nJust call `#to_duration` method on any `Numeric` instance.\n\n```ruby\nirb(main):001:0\u003e 12345.to_duration\n=\u003e \"3 hours, 25 minutes and 45 seconds\"\n\nirb(main):002:0\u003e 1234567890.to_duration\n=\u003e \"39 years, 1 month, 14 days, 5 hours, 31 minutes and 30 seconds\"\n\nirb(main):003:0\u003e 1234567890.to_duration(weeks: true)\n=\u003e \"39 years, 1 month, 2 weeks, 5 hours, 31 minutes and 30 seconds\"\n\nirb(main):004:0\u003e 0.5.to_duration\n=\u003e \"Less than one second\"\n```\n\n### #to_duration(options = {})\n\n| Option | Type | Default |\n|---|:-:|:-:|\n| `:years` | Boolean | `true` |\n| `:months` | Boolean | `true` |\n| `:weeks` | Boolean | `false` |\n| `:days` | Boolean | `true` |\n| `:hours` | Boolean | `true` |\n| `:minutes` | Boolean | `true` |\n| `:seconds` | Boolean | `true` |\n\n**Notice:** Before version `1.2.0` these keys were singular.\n\n## Localization\n\nThe gem uses [I18n](https://github.com/svenfuchs/i18n) for localization.\n\n```yml\nen: # Replace this key with your locale\n  to_duration:\n    and: and\n    less_than_one_second: Less than one second\n    year:\n      one: year\n      other: years\n    month:\n      one: month\n      other: months\n    week:\n      one: week\n      other: weeks\n    day:\n      one: day\n      other: days\n    hour:\n      one: hour\n      other: hours\n    minute:\n      one: minute\n      other: minutes\n    second:\n      one: second\n      other: seconds\n```\n\nIf you're on Rails you may create `config/locales/to_duration_#{locale}.yml` file.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/digaev/to_duration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigaev%2Fto_duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigaev%2Fto_duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigaev%2Fto_duration/lists"}