{"id":13463401,"url":"https://github.com/fnando/recurrence","last_synced_at":"2025-05-15T08:10:40.198Z","repository":{"id":434028,"uuid":"54811","full_name":"fnando/recurrence","owner":"fnando","description":"A simple library that handles recurring events.","archived":false,"fork":false,"pushed_at":"2023-11-22T16:31:25.000Z","size":199,"stargazers_count":568,"open_issues_count":13,"forks_count":53,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-14T14:59:37.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/fnando/recurrence","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/fnando.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2008-09-21T06:53:27.000Z","updated_at":"2025-02-19T00:57:52.000Z","dependencies_parsed_at":"2024-01-13T17:55:36.224Z","dependency_job_id":"5be5cd68-a953-4fa9-a87f-8c920d9e4bac","html_url":"https://github.com/fnando/recurrence","commit_stats":{"total_commits":105,"total_committers":10,"mean_commits":10.5,"dds":"0.32380952380952377","last_synced_commit":"809a38d855e131f244bfee3ef81168bfbb96f138"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Frecurrence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Frecurrence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Frecurrence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Frecurrence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/recurrence/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254286414,"owners_count":22045724,"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-07-31T13:00:52.830Z","updated_at":"2025-05-15T08:10:40.175Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","readme":"# Recurrence\n\nA simple library to handle recurring events.\n\n[![Tests](https://github.com/fnando/recurrence/workflows/ruby-tests/badge.svg)](https://github.com/fnando/recurrence/actions?query=workflow%3ATests)\n[![Gem](https://img.shields.io/gem/v/recurrence.svg)](https://rubygems.org/gems/recurrence)\n[![Gem](https://img.shields.io/gem/dt/recurrence.svg)](https://rubygems.org/gems/recurrence)\n\n## Installation\n\n    gem install recurrence\n\n## Usage\n\n```ruby\nrequire \"rubygems\"\nrequire \"recurrence\"\n\n# Daily\nr = Recurrence.new(every: :day)\nr = Recurrence.new(every: :day, interval: 9)\nr = Recurrence.new(every: :day, repeat: 7)\nr = Recurrence.daily(options = {})\n\n# Weekly\nr = Recurrence.new(every: :week, on: 5)\nr = Recurrence.new(every: :week, on: :monday)\nr = Recurrence.new(every: :week, on: [:monday, :friday])\nr = Recurrence.new(every: :week, on: [:monday, :wednesday, :friday])\nr = Recurrence.new(every: :week, on: :friday, interval: 2)\nr = Recurrence.new(every: :week, on: :friday, repeat: 4)\nr = Recurrence.weekly(on: :thursday)\n\n# Monthly by month day\nr = Recurrence.new(every: :month, on: 15)\nr = Recurrence.new(every: :month, on: 31)\nr = Recurrence.new(every: :month, on: 7, interval: 2)\nr = Recurrence.new(every: :month, on: 7, interval: :monthly)\nr = Recurrence.new(every: :month, on: 7, interval: :bimonthly)\nr = Recurrence.new(every: :month, on: 7, repeat: 6)\nr = Recurrence.monthly(on: 31)\n\n# Monthly by week day\nr = Recurrence.new(every: :month, on: :first, weekday: :sunday)\nr = Recurrence.new(every: :month, on: :third, weekday: :monday)\nr = Recurrence.new(every: :month, on: :last,  weekday: :friday)\nr = Recurrence.new(every: :month, on: :last,  weekday: :friday, interval: 2)\nr = Recurrence.new(every: :month, on: :last,  weekday: :friday, interval: :quarterly)\nr = Recurrence.new(every: :month, on: :last,  weekday: :friday, interval: :semesterly)\nr = Recurrence.new(every: :month, on: :last,  weekday: :friday, repeat: 3)\n\n# Yearly\nr = Recurrence.new(every: :year, on: [7, 4]) # =\u003e [month, day]\nr = Recurrence.new(every: :year, on: [10, 31], interval: 3)\nr = Recurrence.new(every: :year, on: [:jan, 31])\nr = Recurrence.new(every: :year, on: [:january, 31])\nr = Recurrence.new(every: :year, on: [10, 31], repeat: 3)\nr = Recurrence.yearly(on: [:january, 31])\n\n# Limit recurrence\n# :starts defaults to Date.current\n# :until defaults to 2037-12-31\nr = Recurrence.new(every: :day, starts: Date.current)\nr = Recurrence.new(every: :day, until: '2010-01-31')\nr = Recurrence.new(every: :day, starts: Date.current, until: '2010-01-31')\n\n# Generate a collection of events which always includes a final event with the given through date\n# :through defaults to being unset\nr = Recurrence.new(every: :day, through: '2010-01-31')\nr = Recurrence.new(every: :day, starts: Date.current, through: '2010-01-31')\n\n# Remove a date in the series on the given except date(s)\n# :except defaults to being unset\nr = Recurrence.new(every: :day, except: '2010-01-31')\nr = Recurrence.new(every: :day, except: [Date.current, '2010-01-31'])\n\n# Override the next date handler\nr = Recurrence.new(every: :month, on: 1, handler: Proc.new { |day, month, year| raise(\"Date not allowed!\") if year == 2011 \u0026\u0026 month == 12 \u0026\u0026 day == 31 })\n\n# Shift the recurrences to maintain dates around boundaries (Jan 31 -\u003e Feb 28 -\u003e Mar 28)\nr = Recurrence.new(every: :month, on: 31, shift: true)\n\n# Getting an array with all events\nr.events.each {|date| puts date.to_s }  # =\u003e Memoized array\nr.events!.each {|date| puts date.to_s } # =\u003e reset items cache and re-execute it\nr.events(starts: '2009-01-01').each {|date| puts date.to_s }\nr.events(until: '2009-01-10').each {|date| puts date.to_s }\nr.events(through: '2009-01-10').each {|date| puts date.to_s }\nr.events(starts: '2009-01-05', until: '2009-01-10').each {|date| puts date.to_s }\n\n# Iterating events\nr.each { |date| puts date.to_s } # =\u003e Use items method\nr.each! { |date| puts date.to_s } # =\u003e Use items! method\n\n# Check if a date is included\nr.include?(Date.current) # =\u003e true or false\nr.include?('2008-09-21')\n\n# Get next available date\nr.next   # =\u003e Keep the original date object\nr.next! # =\u003e Change the internal date object to the next available date\n```\n\n## Troubleshooting\n\nIf you're having problems because already have a class/module called Recurrence\nthat is conflicting with this gem, you can require the namespace and create a\nclass that inherits from `Recurrence_`.\n\n```ruby\nrequire \"recurrence/namespace\"\n\nclass RecurrentEvent \u003c Recurrence_\nend\n\nr = RecurrentEvent.new(every: :day)\n```\n\nIf you're using Rails/Bundler or something like that, remember to override the\n`:require` option.\n\n```ruby\n# Gemfile\nsource \"https://rubygems.org\"\n\ngem \"recurrence\", require: \"recurrence/namespace\"\n```\n\n## Maintainer\n\n- Nando Vieira (http://nandovieira.com)\n\n## Contributors\n\n- https://github.com/fnando/recurrence/graphs/contributors\n\n## License\n\n(The MIT License)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the 'Software'), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Time \u0026 Space","Ruby"],"sub_categories":["Recurring Events"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Frecurrence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Frecurrence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Frecurrence/lists"}