{"id":16898881,"url":"https://github.com/josedonizetti/ruby-duration","last_synced_at":"2025-03-17T06:31:59.430Z","repository":{"id":1070269,"uuid":"910806","full_name":"josedonizetti/ruby-duration","owner":"josedonizetti","description":"Immutable type that represents some amount of time with accuracy in seconds.","archived":false,"fork":false,"pushed_at":"2021-07-30T15:56:24.000Z","size":186,"stargazers_count":124,"open_issues_count":7,"forks_count":23,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-14T21:55:30.969Z","etag":null,"topics":["duration","ruby","time","value-object"],"latest_commit_sha":null,"homepage":"http://bit.ly/ruby-duration","language":"CSS","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/josedonizetti.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":"2010-09-14T19:42:37.000Z","updated_at":"2024-03-30T13:24:23.000Z","dependencies_parsed_at":"2022-08-16T11:55:26.904Z","dependency_job_id":null,"html_url":"https://github.com/josedonizetti/ruby-duration","commit_stats":null,"previous_names":["peleteiro/ruby-duration"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josedonizetti%2Fruby-duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josedonizetti%2Fruby-duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josedonizetti%2Fruby-duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josedonizetti%2Fruby-duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josedonizetti","download_url":"https://codeload.github.com/josedonizetti/ruby-duration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847061,"owners_count":20357317,"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":["duration","ruby","time","value-object"],"created_at":"2024-10-13T17:45:49.313Z","updated_at":"2025-03-17T06:31:58.595Z","avatar_url":"https://github.com/josedonizetti.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"ruby-duration\n=============\n\nDuration is an immutable type that represents some amount of time with accuracy in seconds.\n\nA lot of the code and inspirations is borrowed from [duration](http://rubyforge.org/projects/duration)\nlib, which is a **mutable** Duration type with lot more features.\n\nHelp Wanted!\n============\n\nIf you use ruby-duration and want to take over the project, let me know.\n\n[![Maintainers Wanted](https://img.shields.io/badge/maintainers-wanted-red.svg)](https://github.com/pickhardt/maintainers-wanted)\n\nFeatures\n--------\n\n  * Representation of time in weeks, days, hours, minutes and seconds.\n  * Construtor can receive the amount of time in seconds or a Hash with unit and amount of time.\n  * Format method to display the time with i18n support.\n  * Mongoid serialization support. Use `require 'duration/mongoid'`.\n  * Tested on mri 1.9.3 and jruby. Kudos to rvm!\n\n\nShow me the code\n----------------\n\n### constructor\n\n    Duration.new(100) =\u003e #\u003cDuration: minutes=1, seconds=40, total=100\u003e\n    Duration.new(:hours =\u003e 5, :minutes =\u003e 70) =\u003e #\u003cDuration: hours=6, minutes=10, total=22200\u003e\n\n### format\n\n    Duration.new(:weeks =\u003e 3, :days =\u003e 1).format(\"%w %~w and %d %~d\") =\u003e \"3 weeks and 1 day\"\n    Duration.new(:weeks =\u003e 1, :days =\u003e 20).format(\"%w %~w and %d %~d\") =\u003e \"3 weeks and 6 days\"\n\n### [iso 8601](http://en.wikipedia.org/wiki/ISO_8601#Durations)\n\n    Duration.new(:weeks =\u003e 1, :days =\u003e 20).iso8601 =\u003e \"P3W6DT0H0M0S\"\n    Duration.new(\"P6DT5S\") =\u003e #\u003cDuration: days=6, seconds=5, total=518405\u003e\n\n### Mongoid support\nThe current version of this gem supports Mongoid \u003e= [3.0.0](https://github.com/mongoid/mongoid).\nFor lower Mongoid versions try:\n * \u003c 3.0.0 tag [v2.1.4](https://github.com/peleteiro/ruby-duration/tree/v2.1.4)\n * \u003c 2.1.0 tag [v1.0.0](https://github.com/peleteiro/ruby-duration/tree/v1.0.0)\n\n```\n    require 'duration/mongoid'\n\n    class MyModel\n      include Mongoid::Document\n      field :duration, type =\u003e Duration\n    end\n```\n\n### Dependencies\nThe current version of this gem runs only on Ruby Versions \u003e= 1.9.3.\nIf you are running a older version of Ruby try:\n* tag [v2.1.4](https://github.com/peleteiro/ruby-duration/tree/v2.1.4)\n\n\nNote on Patches/Pull Requests\n-----------------------------\n\n  * Fork the project.\n  * Make your feature addition or bug fix.\n  * Add tests for it. This is important so I don't break it in a\n    future version unintentionally.\n  * Commit, do not mess with rakefile, version, or history.\n    (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)\n  * Send me a pull request. Bonus points for topic branches.\n\n\nLicense\n---------\nCopyright (c) 2010 Jose Peleteiro\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosedonizetti%2Fruby-duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosedonizetti%2Fruby-duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosedonizetti%2Fruby-duration/lists"}