{"id":20061632,"url":"https://github.com/tylerrick/activesupport-duration-change","last_synced_at":"2025-09-09T18:07:17.039Z","repository":{"id":222916499,"uuid":"758735231","full_name":"TylerRick/activesupport-duration-change","owner":"TylerRick","description":"Methods for changing Durations including #change, #truncate, and #round","archived":false,"fork":false,"pushed_at":"2024-02-17T01:06:40.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-09T19:53:11.597Z","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/TylerRick.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","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}},"created_at":"2024-02-17T00:20:04.000Z","updated_at":"2025-02-26T21:18:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac4f710a-1372-4726-a9bc-ea2bf11dbf12","html_url":"https://github.com/TylerRick/activesupport-duration-change","commit_stats":null,"previous_names":["tylerrick/activesupport-duration-change"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TylerRick/activesupport-duration-change","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TylerRick%2Factivesupport-duration-change","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TylerRick%2Factivesupport-duration-change/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TylerRick%2Factivesupport-duration-change/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TylerRick%2Factivesupport-duration-change/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TylerRick","download_url":"https://codeload.github.com/TylerRick/activesupport-duration-change/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TylerRick%2Factivesupport-duration-change/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274340152,"owners_count":25267290,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-13T13:21:01.886Z","updated_at":"2025-09-09T18:07:17.001Z","avatar_url":"https://github.com/TylerRick.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveSupport::Duration#change  [![Gem Version](https://badge.fury.io/rb/activesupport-duration-change.svg)](https://badge.fury.io/rb/activesupport-duration-change)\n\nChange/manipulate [ActiveSupport::Duration](https://api.rubyonrails.org/classes/ActiveSupport/Duration.html) objects with these added methods:\n\n# API\n\n## `#change`, `#change_cascade`\n\n```ruby\n(9.hours + 10.minutes + 40.seconds).change(hours: 12)             #=\u003e 12 hours, 10 minutes, and 40 seconds\n(9.hours + 10.minutes + 40.seconds).change(hours: 12, minutes: 5) #=\u003e 12 hours, 5 minutes, and 40 seconds\n(9.hours + 10.minutes + 40.seconds).change(minutes: 5)            #=\u003e 9 hours, 5 minutes, and 40 seconds\n\n(9.hours + 10.minutes + 40.seconds).change_cascade(hours: 12)  # =\u003e 12 hours\n(9.hours + 10.minutes + 40.seconds).change_cascade(minutes: 5) # =\u003e 9 hours and 5 minutes\n```\n\n## `#normalize`\n\n```ruby\n90.seconds.normalize                          #=\u003e 1 minute and 30 seconds\n23.hours + 59.minutes + 60.seconds).normalize #=\u003e 1 day\n```\n\n## `#round`\n\n```ruby\n30.seconds.round(:minutes)        #=\u003e 1 minute\n89.seconds.round(:minutes)        #=\u003e 1 minute\n90.seconds.round(:minutes)        #=\u003e 2 minutes\n(1.hour + 30.seconds).round(:minutes)  #=\u003e 1 hour and 1 minute\n\n2.5.seconds.round                 #=\u003e 3 seconds\n2.5.seconds.round(half: :down)    #=\u003e 2 seconds\n```\n\n## `#truncate`\n\n```ruby\n30.seconds.truncate(:minutes)      #=\u003e 0 seconds\n\n# This could be surprising, but remember that it just looks at the values as they exist in each part.\n90.seconds.truncate(:minutes)      #=\u003e 0 seconds\n\n# If needed, you can always normalize the duration first...\n90.seconds.normalize                    #=\u003e 1 minute and 30 seconds\n90.seconds.normalize.truncate(:minutes) #=\u003e 1 minute\n```\n\n## .from_parts\n\n```ruby\n# This is the inverse of #parts.\nduration = ActiveSupport::Duration.from_parts({hours: 9, minutes: 10, seconds: 40})\n```\n\n# Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activesupport-duration-change'\n```\n\n# See also\n\n- [activesupport-duration-human_string](https://github.com/TylerRick/activesupport-duration-human_string), which lets you convert `Duration` objects to human-friendly strings like '2h 30m 17s'\n\n# Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n# Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/TylerRick/activesupport-duration-change.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftylerrick%2Factivesupport-duration-change","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftylerrick%2Factivesupport-duration-change","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftylerrick%2Factivesupport-duration-change/lists"}